changeset 8695:9a89253a32e6

heads: show closed heads only when --closed is passed Add a --closed (-c) option to 'hg heads' to show all heads and change the default behavior to refrain from showing fully closed branches. Enhance 'hg heads <branch>' so that: * default: displays normal & inactive heads, not closed heads * --closed: displays normal, inactive & closed heads * --active: displays only normal heads * both --closed and --active: displays normal & closed heads only
author John Mulligan <phlogistonjohn@asynchrono.us>
date Wed, 03 Jun 2009 13:59:38 +0200
parents ca8d05e1f1d1
children 73aa0510740d
files mercurial/commands.py tests/test-branches tests/test-debugcomplete.out
diffstat 3 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Jun 03 13:42:55 2009 +0200
+++ b/mercurial/commands.py	Wed Jun 03 13:59:38 2009 +0200
@@ -1317,11 +1317,14 @@
         start = repo.lookup(opts['rev'])
     else:
         start = None
-    closed = not opts.get('active')
+    closed = opts.get('closed')
+    hideinactive, _heads = opts.get('active'), None
     if not branchrevs:
         # Assume we're looking repo-wide heads if no revs were specified.
         heads = repo.heads(start, closed=closed)
     else:
+        if hideinactive:
+            _heads = repo.heads(start, closed=closed)
         heads = []
         visitedset = set()
         for branchrev in branchrevs:
@@ -1338,6 +1341,8 @@
                 else:
                     ui.warn(_("no changes on branch %s are reachable from %s\n")
                             % (branch, opts.get('rev')))
+            if hideinactive:
+                bheads = [bhead for bhead in bheads if bhead in _heads]
             heads.extend(bheads)
     if not heads:
         return 1
@@ -3237,6 +3242,8 @@
          [('r', 'rev', '', _('show only heads which are descendants of REV')),
           ('a', 'active', False,
            _('show only the active heads from open branches')),
+          ('c', 'closed', False,
+           _('show normal and closed heads')),
          ] + templateopts,
          _('[-r REV] [REV]...')),
     "help": (help_, [], _('[TOPIC]')),
--- a/tests/test-branches	Wed Jun 03 13:42:55 2009 +0200
+++ b/tests/test-branches	Wed Jun 03 13:59:38 2009 +0200
@@ -62,8 +62,8 @@
 echo 'xxx3' >> b
 hg commit -d '9 0' -m 'adding another cset to branch b'
 hg branches
+hg heads --closed
 hg heads
-hg heads -a
 hg commit -d '9 0' --close-branch -m 'prune bad branch'
 hg branches -a
 hg up -C b
@@ -75,5 +75,5 @@
 hg commit -d '9 0' -m 'reopen branch with a change'
 echo '--- branch b is back in action'
 hg branches -a
+hg heads -c
 hg heads
-hg heads -a
--- a/tests/test-debugcomplete.out	Wed Jun 03 13:42:55 2009 +0200
+++ b/tests/test-debugcomplete.out	Wed Jun 03 13:59:38 2009 +0200
@@ -201,7 +201,7 @@
 debugstate: nodates
 debugwalk: include, exclude
 grep: print0, all, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
-heads: rev, active, style, template
+heads: rev, active, closed, style, template
 help: 
 identify: rev, num, id, branch, tags
 import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity