changeset 4316:c3a68137453a

pull requests: tweak default selections for repos
author Mads Kiilerich <madski@unity3d.com>
date Tue, 10 Dec 2013 19:30:37 +0100
parents 8f5ecadb7ec1
children 205521e789ec
files kallithea/controllers/pullrequests.py
diffstat 1 files changed, 14 insertions(+), 9 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
@@ -89,8 +89,10 @@
 
         if branch_rev:
             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
+            # a revset not restricting to merge() would be better
+            # (especially because it would get the branch point)
+            # ... but is currently too expensive
+            # including branches of children could be nice too
             peerbranches = set()
             for i in repo._repo.revs(
                 "sort(parents(branch(id(%s)) and merge()) - branch(id(%s)), -rev)",
@@ -110,15 +112,18 @@
             if rev == branchrev:
                 selected = n
             if branch == abranch:
+                if not rev:
+                    selected = n
+                branch = None
+        if branch:  # branch not in list - it is probably closed
+            branchrev = repo.closed_branches.get(branch)
+            if branchrev:
+                n = 'branch:%s:%s' % (branch, branchrev)
+                branches.append((n, _('%s (closed)') % branch))
                 selected = n
                 branch = None
-
-        if branch:  # branch not in list - it is probably closed
-            revs = repo._repo.revs('max(branch(%s))', branch)
-            if revs:
-                cs = repo.get_changeset(revs[0])
-                selected = 'branch:%s:%s' % (branch, cs.raw_id)
-                branches.append((selected, branch))
+            if branch:
+                log.error('branch %r not found in %s', branch, repo)
 
         bookmarks = []
         for bookmark, bookmarkrev in repo.bookmarks.iteritems():