changeset 10328:0798a3d5f812

commands: simplify heads a little bit before I start hacking it up
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Sat, 06 Feb 2010 11:29:48 +0100
parents 32197f7eceb3
children ae0ae8691e47
files mercurial/commands.py
diffstat 1 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Feb 06 11:29:23 2010 +0100
+++ b/mercurial/commands.py	Sat Feb 06 11:29:48 2010 +0100
@@ -1409,10 +1409,12 @@
     If STARTREV is specified, only those heads that are descendants of
     STARTREV will be displayed.
     """
+
     if opts.get('rev'):
         start = repo.lookup(opts['rev'])
     else:
         start = None
+
     closed = opts.get('closed')
     hideinactive, _heads = opts.get('active'), None
     if not branchrevs:
@@ -1420,19 +1422,18 @@
             raise error.Abort(_('you must specify a branch to use --closed'))
         # Assume we're looking repo-wide heads if no revs were specified.
         heads = repo.heads(start)
+
     else:
         if hideinactive:
-            _heads = repo.heads(start)
+            dagheads = repo.heads(start)
+        decode, encode = encoding.fromlocal, encoding.tolocal
+        branches = set(repo[decode(br)].branch() for br in branchrevs)
         heads = []
         visitedset = set()
-        for branchrev in branchrevs:
-            branch = repo[encoding.fromlocal(branchrev)].branch()
-            encodedbranch = encoding.tolocal(branch)
-            if branch in visitedset:
-                continue
-            visitedset.add(branch)
+        for b in branches:
             bheads = repo.branchheads(branch, start, closed=closed)
             if not bheads:
+                encodedbranch = encode(b)
                 if not opts.get('rev'):
                     ui.warn(_("no open branch heads on branch %s\n")
                             % encodedbranch)
@@ -1444,10 +1445,12 @@
                     ui.warn(_("no changes on branch %s are reachable from %s\n")
                             % (encodedbranch, opts.get('rev')))
             if hideinactive:
-                bheads = [bhead for bhead in bheads if bhead in _heads]
+                bheads = [bhead for bhead in bheads if bhead in dagheads]
             heads.extend(bheads)
+
     if not heads:
         return 1
+
     displayer = cmdutil.show_changeset(ui, repo, opts)
     for n in heads:
         displayer.show(repo[n])