comparison mercurial/commands.py @ 8991:7e0b31dfc66f

branches: add --closed flag for consistency with heads
author Matt Mackall <mpm@selenic.com>
date Wed, 01 Jul 2009 00:31:59 -0500
parents 8358cf63f612
children ff7d899a7a71
comparison
equal deleted inserted replaced
8990:627399330c7d 8991:7e0b31dfc66f
434 repo.dirstate.setbranch(encoding.fromlocal(label)) 434 repo.dirstate.setbranch(encoding.fromlocal(label))
435 ui.status(_('marked working directory as branch %s\n') % label) 435 ui.status(_('marked working directory as branch %s\n') % label)
436 else: 436 else:
437 ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch())) 437 ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch()))
438 438
439 def branches(ui, repo, active=False): 439 def branches(ui, repo, active=False, closed=False):
440 """list repository named branches 440 """list repository named branches
441 441
442 List the repository's named branches, indicating which ones are 442 List the repository's named branches, indicating which ones are
443 inactive. If -a/--active is specified, only show active branches. 443 inactive. If -c/--closed is specified, also list branches which have
444 444 been marked closed (see hg commit --close-branch).
445 A branch is considered active if it contains repository heads. 445
446 If -a/--active is specified, only show active branches. A branch
447 is considered active if it contains repository heads.
446 448
447 Use the command 'hg update' to switch to an existing branch. 449 Use the command 'hg update' to switch to an existing branch.
448 """ 450 """
451
449 hexfunc = ui.debugflag and hex or short 452 hexfunc = ui.debugflag and hex or short
450 activebranches = [encoding.tolocal(repo[n].branch()) 453 activebranches = [encoding.tolocal(repo[n].branch())
451 for n in repo.heads()] 454 for n in repo.heads()]
452 def testactive(tag, node): 455 def testactive(tag, node):
453 realhead = tag in activebranches 456 realhead = tag in activebranches
464 else: 467 else:
465 hn = repo.lookup(node) 468 hn = repo.lookup(node)
466 if isactive: 469 if isactive:
467 notice = '' 470 notice = ''
468 elif hn not in repo.branchheads(tag, closed=False): 471 elif hn not in repo.branchheads(tag, closed=False):
472 if not closed:
473 continue
469 notice = ' (closed)' 474 notice = ' (closed)'
470 else: 475 else:
471 notice = ' (inactive)' 476 notice = ' (inactive)'
472 rev = str(node).rjust(31 - encoding.colwidth(tag)) 477 rev = str(node).rjust(31 - encoding.colwidth(tag))
473 data = tag, rev, hexfunc(hn), notice 478 data = tag, rev, hexfunc(hn), notice
3203 ('C', 'clean', None, _('reset branch name to parent branch name'))], 3208 ('C', 'clean', None, _('reset branch name to parent branch name'))],
3204 _('[-fC] [NAME]')), 3209 _('[-fC] [NAME]')),
3205 "branches": 3210 "branches":
3206 (branches, 3211 (branches,
3207 [('a', 'active', False, 3212 [('a', 'active', False,
3208 _('show only branches that have unmerged heads'))], 3213 _('show only branches that have unmerged heads')),
3214 ('c', 'closed', False,
3215 _('show normal and closed heads'))],
3209 _('[-a]')), 3216 _('[-a]')),
3210 "bundle": 3217 "bundle":
3211 (bundle, 3218 (bundle,
3212 [('f', 'force', None, 3219 [('f', 'force', None,
3213 _('run even when remote repository is unrelated')), 3220 _('run even when remote repository is unrelated')),