comparison mercurial/commands.py @ 8695:9a89253a32e6

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 <branch>' 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
author John Mulligan <phlogistonjohn@asynchrono.us>
date Wed, 03 Jun 2009 13:59:38 +0200
parents 32537b12e091
children 27a103df29b7
comparison
equal deleted inserted replaced
8694:ca8d05e1f1d1 8695:9a89253a32e6
1315 """ 1315 """
1316 if opts.get('rev'): 1316 if opts.get('rev'):
1317 start = repo.lookup(opts['rev']) 1317 start = repo.lookup(opts['rev'])
1318 else: 1318 else:
1319 start = None 1319 start = None
1320 closed = not opts.get('active') 1320 closed = opts.get('closed')
1321 hideinactive, _heads = opts.get('active'), None
1321 if not branchrevs: 1322 if not branchrevs:
1322 # Assume we're looking repo-wide heads if no revs were specified. 1323 # Assume we're looking repo-wide heads if no revs were specified.
1323 heads = repo.heads(start, closed=closed) 1324 heads = repo.heads(start, closed=closed)
1324 else: 1325 else:
1326 if hideinactive:
1327 _heads = repo.heads(start, closed=closed)
1325 heads = [] 1328 heads = []
1326 visitedset = set() 1329 visitedset = set()
1327 for branchrev in branchrevs: 1330 for branchrev in branchrevs:
1328 branch = repo[branchrev].branch() 1331 branch = repo[branchrev].branch()
1329 if branch in visitedset: 1332 if branch in visitedset:
1336 "reachable from %s\n") 1339 "reachable from %s\n")
1337 % (branch, branchrev, opts.get('rev'))) 1340 % (branch, branchrev, opts.get('rev')))
1338 else: 1341 else:
1339 ui.warn(_("no changes on branch %s are reachable from %s\n") 1342 ui.warn(_("no changes on branch %s are reachable from %s\n")
1340 % (branch, opts.get('rev'))) 1343 % (branch, opts.get('rev')))
1344 if hideinactive:
1345 bheads = [bhead for bhead in bheads if bhead in _heads]
1341 heads.extend(bheads) 1346 heads.extend(bheads)
1342 if not heads: 1347 if not heads:
1343 return 1 1348 return 1
1344 displayer = cmdutil.show_changeset(ui, repo, opts) 1349 displayer = cmdutil.show_changeset(ui, repo, opts)
1345 for n in heads: 1350 for n in heads:
3235 "heads": 3240 "heads":
3236 (heads, 3241 (heads,
3237 [('r', 'rev', '', _('show only heads which are descendants of REV')), 3242 [('r', 'rev', '', _('show only heads which are descendants of REV')),
3238 ('a', 'active', False, 3243 ('a', 'active', False,
3239 _('show only the active heads from open branches')), 3244 _('show only the active heads from open branches')),
3245 ('c', 'closed', False,
3246 _('show normal and closed heads')),
3240 ] + templateopts, 3247 ] + templateopts,
3241 _('[-r REV] [REV]...')), 3248 _('[-r REV] [REV]...')),
3242 "help": (help_, [], _('[TOPIC]')), 3249 "help": (help_, [], _('[TOPIC]')),
3243 "identify|id": 3250 "identify|id":
3244 (identify, 3251 (identify,