changeset 4315:8f5ecadb7ec1

pull requests: preserve ordering of peer-selected branches
author Mads Kiilerich <madski@unity3d.com>
date Tue, 10 Dec 2013 19:30:37 +0100
parents d80689aa938d
children c3a68137453a
files kallithea/controllers/pullrequests.py
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/pullrequests.py	Tue Dec 10 19:30:37 2013 +0100
+++ b/kallithea/controllers/pullrequests.py	Tue Dec 10 19:30:37 2013 +0100
@@ -91,15 +91,15 @@
             branch_rev = safe_str(branch_rev)
             # not restricting to merge() would also get branch point and be better
             # (especially because it would get the branch point) ... but is currently too expensive
-            otherbranches = {}
+            peerbranches = set()
             for i in repo._repo.revs(
-                "sort(parents(branch(id(%s)) and merge()) - branch(id(%s)))",
+                "sort(parents(branch(id(%s)) and merge()) - branch(id(%s)), -rev)",
                 branch_rev, branch_rev):
-                cs = repo.get_changeset(i)
-                otherbranches[cs.branch] = repo.get_changeset(cs.branch).raw_id
-            for abranch, node in otherbranches.iteritems():
-                selected = 'branch:%s:%s' % (abranch, node)
-                peers.append((selected, abranch))
+                abranch = repo.get_changeset(i).branch
+                if abranch not in peerbranches:
+                    n = 'branch:%s:%s' % (abranch, repo.get_changeset(abranch).raw_id)
+                    peers.append((n, abranch))
+                    peerbranches.add(abranch)
 
         selected = None