Mercurial > hg
changeset 6631:a2b13cac0922
Active branches fix (issue1104)
author | Stefano Tortarolo <stefano.tortarolo@gmail.com> |
---|---|
date | Thu, 29 May 2008 22:21:29 +0200 |
parents | 8542fac26f63 |
children | aa3f61884a48 1603bba96411 |
files | mercurial/commands.py tests/test-branches tests/test-branches.out tests/test-convert-svn-branches.out |
diffstat | 4 files changed, 28 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Mon May 26 14:20:26 2008 +0200 +++ b/mercurial/commands.py Thu May 29 22:21:29 2008 +0200 @@ -371,30 +371,26 @@ List the repository's named branches, indicating which ones are inactive. If active is specified, only show active branches. - A branch is considered active if it contains unmerged heads. + A branch is considered active if it contains repository heads. Use the command 'hg update' to switch to an existing branch. """ - b = repo.branchtags() - heads = dict.fromkeys(repo.heads(), 1) - l = [((n in heads), repo.changelog.rev(n), n, t) for t, n in b.items()] - l.sort() - l.reverse() - for ishead, r, n, t in l: - if active and not ishead: - # If we're only displaying active branches, abort the loop on - # encountering the first inactive head - break - else: - hexfunc = ui.debugflag and hex or short + hexfunc = ui.debugflag and hex or short + activebranches = [util.tolocal(repo.changectx(n).branch()) + for n in repo.heads()] + branches = [(tag in activebranches, repo.changelog.rev(node), tag) + for tag, node in repo.branchtags().items()] + branches.sort(reverse=True) + + for isactive, node, tag in branches: + if (not active) or isactive: if ui.quiet: - ui.write("%s\n" % t) + ui.write("%s\n" % tag) else: - spaces = " " * (30 - util.locallen(t)) - # The code only gets here if inactive branches are being - # displayed or the branch is active. - isinactive = ((not ishead) and " (inactive)") or '' - ui.write("%s%s %s:%s%s\n" % (t, spaces, r, hexfunc(n), isinactive)) + rev = str(node).rjust(32 - util.locallen(tag)) + isinactive = ((not isactive) and " (inactive)") or '' + data = tag, rev, hexfunc(repo.lookup(node)), isinactive + ui.write("%s%s:%s%s\n" % data) def bundle(ui, repo, fname, dest=None, **opts): """create a changegroup file
--- a/tests/test-branches Mon May 26 14:20:26 2008 +0200 +++ b/tests/test-branches Thu May 29 22:21:29 2008 +0200 @@ -31,6 +31,11 @@ hg branch c hg commit -d '5 0' -u test -m "Adding c branch" +echo 'd' >d +hg add d +hg branch d +hg commit -d '6 0' -u test -m "Adding d branch" + hg branches echo '-------' hg branches -a
--- a/tests/test-branches.out Mon May 26 14:20:26 2008 +0200 +++ b/tests/test-branches.out Thu May 29 22:21:29 2008 +0200 @@ -5,12 +5,15 @@ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved created new head marked working directory as branch c -c 5:5ca481e59b8c +marked working directory as branch d +d 6:9c581c5ff105 +b 4:22df7444f7c1 a 1:dd6b440dd85a -b 4:22df7444f7c1 (inactive) +c 5:5ca481e59b8c (inactive) default 0:19709c5a4e75 (inactive) ------- -c 5:5ca481e59b8c +d 6:9c581c5ff105 +b 4:22df7444f7c1 a 1:dd6b440dd85a --- Branch a changeset: 1:dd6b440dd85a