[PATCH 3 of 4] do not display closed heads in 'hg heads' by default

John Mulligan phlogistonjohn at asynchrono.us
Tue Jun 2 18:14:45 CDT 2009


# HG changeset patch
# User John Mulligan <phlogistonjohn at asynchrono.us>
# Date 1243983873 14400
# Node ID f3ac8bdab897c9eb5d963c4109ea5903406588fb
# Parent  5291dd080332aef4478e064b354a340c7251d9fd
do not display closed heads in 'hg heads' by default

add --closed (-c) option to 'hg heads' to show all heads
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

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1319,11 +1319,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:
@@ -1340,7 +1343,10 @@
                 else:
                     ui.warn(_("no changes on branch %s are reachable from %s\n")
                             % (branch, opts.get('rev')))
-            heads.extend(bheads)
+            if hideinactive:
+                heads.extend([bhead for bhead in bheads if bhead in _heads])
+            else:
+                heads.extend(bheads)
     if not heads:
         return 1
     displayer = cmdutil.show_changeset(ui, repo, opts)
@@ -3240,6 +3246,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]')),


More information about the Mercurial-devel mailing list