diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -436,16 +436,19 @@ def branch(ui, repo, label=None, **opts) else: ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch())) -def branches(ui, repo, active=False): +def branches(ui, repo, active=False, closed=False): """list repository named branches List the repository's named branches, indicating which ones are - inactive. If -a/--active is specified, only show active branches. - - A branch is considered active if it contains repository heads. + inactive. If -c/--closed is specified, also list branches which have + been marked closed (see hg commit --close-branch). + + If -a/--active is specified, only show active branches. A branch + is considered active if it contains repository heads. Use the command 'hg update' to switch to an existing branch. """ + hexfunc = ui.debugflag and hex or short activebranches = [encoding.tolocal(repo[n].branch()) for n in repo.heads()] @@ -466,6 +469,8 @@ def branches(ui, repo, active=False): if isactive: notice = '' elif hn not in repo.branchheads(tag, closed=False): + if not closed: + continue notice = ' (closed)' else: notice = ' (inactive)' @@ -3205,7 +3210,9 @@ table = { "branches": (branches, [('a', 'active', False, - _('show only branches that have unmerged heads'))], + _('show only branches that have unmerged heads')), + ('c', 'closed', False, + _('show normal and closed heads'))], _('[-a]')), "bundle": (bundle, diff --git a/tests/test-branches b/tests/test-branches --- a/tests/test-branches +++ b/tests/test-branches @@ -70,6 +70,7 @@ hg up -C b hg commit -d '9 0' --close-branch -m 'close this part branch too' echo '--- b branch should be inactive' hg branches +hg branches -c hg branches -a hg heads b hg heads --closed b diff --git a/tests/test-branches.out b/tests/test-branches.out --- a/tests/test-branches.out +++ b/tests/test-branches.out @@ -108,6 +108,10 @@ a branch name much longer than the defau 1 files updated, 0 files merged, 0 files removed, 0 files unresolved --- b branch should be inactive a branch name much longer than the default justification used by branches 7:10ff5895aa57 +c 6:589736a22561 (inactive) +a 5:d8cbc61dbaa6 (inactive) +default 0:19709c5a4e75 (inactive) +a branch name much longer than the default justification used by branches 7:10ff5895aa57 b 12:2da6583810df (closed) c 6:589736a22561 (inactive) a 5:d8cbc61dbaa6 (inactive) diff --git a/tests/test-debugcomplete.out b/tests/test-debugcomplete.out --- a/tests/test-debugcomplete.out +++ b/tests/test-debugcomplete.out @@ -184,7 +184,7 @@ archive: no-decode, prefix, rev, type, i backout: merge, parent, rev, include, exclude, message, logfile, date, user bisect: reset, good, bad, skip, command, noupdate branch: force, clean -branches: active +branches: active, closed bundle: force, rev, base, all, type, ssh, remotecmd cat: output, rev, decode, include, exclude copy: after, force, include, exclude, dry-run