# HG changeset patch # User John Mulligan # Date 1244030378 -7200 # Node ID 9a89253a32e6ebec971701b2008eb1d887de9d8b # Parent ca8d05e1f1d19a0870ef6cf0afe86f1d4153df83 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 ' 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 -r ca8d05e1f1d1 -r 9a89253a32e6 mercurial/commands.py --- 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]')), diff -r ca8d05e1f1d1 -r 9a89253a32e6 tests/test-branches --- 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 diff -r ca8d05e1f1d1 -r 9a89253a32e6 tests/test-debugcomplete.out --- 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