comparison mercurial/commands.py @ 7656:6a24fb994701

branch closing: referencing open and closed branches/heads Treat fully closed branches similarly to "inactive" in the output of 'hg branches'. They will be suffixed with "(closed)" where inactive branches are marked with "(inactive)". If the -a/--active option is given both inactive and closed branches will not be shown. Partially closed branches (multiple heads, at least one not closed) will display the next (tipmost) open head. Add -a/--active option to "hg heads" which will hide closed heads iff the option is specified. In other hg commands, when multiple branch heads exist the branch name will refer to the tipmost open head, and if none exist, then the tipmost closed head.
author John Mulligan <phlogistonjohn@asynchrono.us>
date Wed, 14 Jan 2009 21:47:38 -0500
parents cce37dab7ad6
children ee3364d3d859
comparison
equal deleted inserted replaced
7655:cce37dab7ad6 7656:6a24fb994701
429 429
430 Use the command 'hg update' to switch to an existing branch. 430 Use the command 'hg update' to switch to an existing branch.
431 """ 431 """
432 hexfunc = ui.debugflag and hex or short 432 hexfunc = ui.debugflag and hex or short
433 activebranches = [util.tolocal(repo[n].branch()) 433 activebranches = [util.tolocal(repo[n].branch())
434 for n in repo.heads()] 434 for n in repo.heads(closed=False)]
435 branches = util.sort([(tag in activebranches, repo.changelog.rev(node), tag) 435 branches = util.sort([(tag in activebranches, repo.changelog.rev(node), tag)
436 for tag, node in repo.branchtags().items()]) 436 for tag, node in repo.branchtags().items()])
437 branches.reverse() 437 branches.reverse()
438 438
439 for isactive, node, tag in branches: 439 for isactive, node, tag in branches:
440 if (not active) or isactive: 440 if (not active) or isactive:
441 if ui.quiet: 441 if ui.quiet:
442 ui.write("%s\n" % tag) 442 ui.write("%s\n" % tag)
443 else: 443 else:
444 hn = repo.lookup(node)
445 if isactive:
446 notice = ''
447 elif hn not in repo.branchheads(tag, closed=False):
448 notice = ' (closed)'
449 else:
450 notice = ' (inactive)'
444 rev = str(node).rjust(31 - util.locallen(tag)) 451 rev = str(node).rjust(31 - util.locallen(tag))
445 isinactive = ((not isactive) and " (inactive)") or '' 452 data = tag, rev, hexfunc(hn), notice
446 data = tag, rev, hexfunc(repo.lookup(node)), isinactive
447 ui.write("%s %s:%s%s\n" % data) 453 ui.write("%s %s:%s%s\n" % data)
448 454
449 def bundle(ui, repo, fname, dest=None, **opts): 455 def bundle(ui, repo, fname, dest=None, **opts):
450 """create a changegroup file 456 """create a changegroup file
451 457
1264 """ 1270 """
1265 if opts.get('rev'): 1271 if opts.get('rev'):
1266 start = repo.lookup(opts['rev']) 1272 start = repo.lookup(opts['rev'])
1267 else: 1273 else:
1268 start = None 1274 start = None
1275 closed = not opts.get('active')
1269 if not branchrevs: 1276 if not branchrevs:
1270 # Assume we're looking repo-wide heads if no revs were specified. 1277 # Assume we're looking repo-wide heads if no revs were specified.
1271 heads = repo.heads(start) 1278 heads = repo.heads(start, closed=closed)
1272 else: 1279 else:
1273 heads = [] 1280 heads = []
1274 visitedset = util.set() 1281 visitedset = util.set()
1275 for branchrev in branchrevs: 1282 for branchrev in branchrevs:
1276 branch = repo[branchrev].branch() 1283 branch = repo[branchrev].branch()
1277 if branch in visitedset: 1284 if branch in visitedset:
1278 continue 1285 continue
1279 visitedset.add(branch) 1286 visitedset.add(branch)
1280 bheads = repo.branchheads(branch, start) 1287 bheads = repo.branchheads(branch, start, closed=closed)
1281 if not bheads: 1288 if not bheads:
1282 if branch != branchrev: 1289 if branch != branchrev:
1283 ui.warn(_("no changes on branch %s containing %s are " 1290 ui.warn(_("no changes on branch %s containing %s are "
1284 "reachable from %s\n") 1291 "reachable from %s\n")
1285 % (branch, branchrev, opts.get('rev'))) 1292 % (branch, branchrev, opts.get('rev')))
3213 ] + walkopts, 3220 ] + walkopts,
3214 _('[OPTION]... PATTERN [FILE]...')), 3221 _('[OPTION]... PATTERN [FILE]...')),
3215 "heads": 3222 "heads":
3216 (heads, 3223 (heads,
3217 [('r', 'rev', '', _('show only heads which are descendants of rev')), 3224 [('r', 'rev', '', _('show only heads which are descendants of rev')),
3225 ('a', 'active', False,
3226 _('show only the active heads from open branches')),
3218 ] + templateopts, 3227 ] + templateopts,
3219 _('[-r REV] [REV]...')), 3228 _('[-r REV] [REV]...')),
3220 "help": (help_, [], _('[TOPIC]')), 3229 "help": (help_, [], _('[TOPIC]')),
3221 "identify|id": 3230 "identify|id":
3222 (identify, 3231 (identify,