[damned-lies] Restored branch sort algorithm
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Restored branch sort algorithm
- Date: Thu, 27 Aug 2015 14:32:28 +0000 (UTC)
commit 9917d8d45dc4a8e6d173d9fbeed458cab832ee30
Author: Claude Paroz <claude 2xlibre net>
Date: Thu Aug 27 16:31:54 2015 +0200
Restored branch sort algorithm
stats/models.py | 4 ++--
stats/tests/tests.py | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 0fca5a8..50cd53d 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -252,9 +252,9 @@ class Branch(models.Model):
def __lt__(self, other):
if self.name in BRANCH_HEAD_NAMES:
- return False
- elif other.name in BRANCH_HEAD_NAMES:
return True
+ elif other.name in BRANCH_HEAD_NAMES:
+ return False
return (self.weight, self.name) < (other.weight, other.name)
@property
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index df3cb30..51fbc55 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -177,17 +177,17 @@ class ModuleTestCase(TestCase):
b2.save(update_statistics=False)
self.assertEqual(
[b.name for b in sorted(self.mod.branch_set.all())],
- ['a-branch', 'p-branch', 'master']
+ ['master', 'a-branch', 'p-branch']
)
b2.weight = -1
b2.save(update_statistics=False)
self.assertEqual(
[b.name for b in sorted(self.mod.branch_set.all())],
- ['p-branch', 'a-branch', 'master']
+ ['master', 'p-branch', 'a-branch']
)
self.assertEqual(
[b.name for b in self.mod.get_branches(reverse=True)],
- ['master', 'a-branch', 'p-branch']
+ ['a-branch', 'p-branch', 'master']
)
@test_scratchdir
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]