commands: externalize branchheads so we can do it for all branches at once
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Sat, 06 Feb 2010 19:06:02 +0100
changeset 10348 0fc5222c0951
parent 10347 7516716e56dc
child 10349 20356e69710c
commands: externalize branchheads so we can do it for all branches at once
mercurial/commands.py
--- a/mercurial/commands.py	Sat Feb 06 19:33:33 2010 +0100
+++ b/mercurial/commands.py	Sat Feb 06 19:06:02 2010 +0100
@@ -1423,12 +1423,18 @@
     else:
 
         decode, encode = encoding.fromlocal, encoding.tolocal
+        heads = []
         branches = set(repo[decode(br)].branch() for br in branchrevs)
-        heads = []
-
-        for b in branches:
-            bheads = repo.branchheads(b, start, True)
-            heads.extend(bheads)
+        for b, ls in repo.branchmap().iteritems():
+            if b not in branches:
+                continue
+            if start is None:
+                heads += ls
+                continue
+            startrev = repo.changelog.rev(start)
+            descendants = set(repo.changelog.descendants(startrev))
+            descendants.add(startrev)
+            heads += [h for h in ls if repo.changelog.rev(h) in descendants]
 
         if not opts.get('closed'):
             heads = [h for h in heads if not repo[h].extra().get('close')]