Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 8796:2bcef677a6c3
localrepo: remove 'closed' argument to heads(...) function
- repository heads are not associated with the closed attribute, so
remove it making the code in line with the concept.
- Fix functions that were calling heads with the parameter.
- Adjust webcommands.branches to include the concept of inactive
as well as open and closed branches
- Fix code and docstrings in commands to make the correct use of
closed branches & branch heads clearer
- Improve grammar of 'hg heads' help text (2nd submission)
this does not alter the cli for hg branches, that work is
still to be done
author | John Mulligan <phlogistonjohn@asynchrono.us> |
---|---|
date | Wed, 10 Jun 2009 19:11:49 -0400 |
parents | 708938509732 |
children | 14a0bdd59848 |
comparison
equal
deleted
inserted
replaced
8795:51c29aec0b75 | 8796:2bcef677a6c3 |
---|---|
444 | 444 |
445 Use the command 'hg update' to switch to an existing branch. | 445 Use the command 'hg update' to switch to an existing branch. |
446 """ | 446 """ |
447 hexfunc = ui.debugflag and hex or short | 447 hexfunc = ui.debugflag and hex or short |
448 activebranches = [encoding.tolocal(repo[n].branch()) | 448 activebranches = [encoding.tolocal(repo[n].branch()) |
449 for n in repo.heads(closed=False)] | 449 for n in repo.heads()] |
450 branches = sorted([(tag in activebranches, repo.changelog.rev(node), tag) | 450 def testactive(tag, node): |
451 realhead = tag in activebranches | |
452 open = node in repo.branchheads(tag, closed=False) | |
453 return realhead and open | |
454 branches = sorted([(testactive(tag, node), repo.changelog.rev(node), tag) | |
451 for tag, node in repo.branchtags().items()], | 455 for tag, node in repo.branchtags().items()], |
452 reverse=True) | 456 reverse=True) |
453 | 457 |
454 for isactive, node, tag in branches: | 458 for isactive, node, tag in branches: |
455 if (not active) or isactive: | 459 if (not active) or isactive: |
1300 def heads(ui, repo, *branchrevs, **opts): | 1304 def heads(ui, repo, *branchrevs, **opts): |
1301 """show current repository heads or show branch heads | 1305 """show current repository heads or show branch heads |
1302 | 1306 |
1303 With no arguments, show all repository head changesets. | 1307 With no arguments, show all repository head changesets. |
1304 | 1308 |
1305 If branch names or revisions are given this will show the heads of | |
1306 the specified branches or the branches those revisions are tagged | |
1307 with. | |
1308 | |
1309 Repository "heads" are changesets that don't have child | 1309 Repository "heads" are changesets that don't have child |
1310 changesets. They are where development generally takes place and | 1310 changesets. They are where development generally takes place and |
1311 are the usual targets for update and merge operations. | 1311 are the usual targets for update and merge operations. |
1312 | 1312 |
1313 Branch heads are changesets that have a given branch tag, but have | 1313 If one or more REV is given, the "branch heads" will be shown for |
1314 no child changesets with that tag. They are usually where | 1314 the named branch associated with that revision. The name of the |
1315 development on a given branch takes place. | 1315 branch is called the revision's branch tag. |
1316 | |
1317 Branch heads are revisions on a given named branch that do not have | |
1318 any children on the same branch. A branch head could be a true head | |
1319 or it could be the last changeset on a branch before a new branch | |
1320 was created. If none of the branch heads are true heads, the branch | |
1321 is considered inactive. | |
1322 | |
1323 If STARTREV is specified only those heads (or branch heads) that | |
1324 are descendants of STARTREV will be displayed. | |
1316 """ | 1325 """ |
1317 if opts.get('rev'): | 1326 if opts.get('rev'): |
1318 start = repo.lookup(opts['rev']) | 1327 start = repo.lookup(opts['rev']) |
1319 else: | 1328 else: |
1320 start = None | 1329 start = None |
1321 closed = opts.get('closed') | 1330 closed = opts.get('closed') |
1322 hideinactive, _heads = opts.get('active'), None | 1331 hideinactive, _heads = opts.get('active'), None |
1323 if not branchrevs: | 1332 if not branchrevs: |
1324 # Assume we're looking repo-wide heads if no revs were specified. | 1333 # Assume we're looking repo-wide heads if no revs were specified. |
1325 heads = repo.heads(start, closed=closed) | 1334 heads = repo.heads(start) |
1326 else: | 1335 else: |
1327 if hideinactive: | 1336 if hideinactive: |
1328 _heads = repo.heads(start, closed=closed) | 1337 _heads = repo.heads(start) |
1329 heads = [] | 1338 heads = [] |
1330 visitedset = set() | 1339 visitedset = set() |
1331 for branchrev in branchrevs: | 1340 for branchrev in branchrevs: |
1332 branch = repo[branchrev].branch() | 1341 branch = repo[branchrev].branch() |
1333 if branch in visitedset: | 1342 if branch in visitedset: |
1334 continue | 1343 continue |
1335 visitedset.add(branch) | 1344 visitedset.add(branch) |
1336 bheads = repo.branchheads(branch, start, closed=closed) | 1345 bheads = repo.branchheads(branch, start, closed=closed) |
1337 if not bheads: | 1346 if not bheads: |
1338 if branch != branchrev: | 1347 if not opts.get('rev'): |
1348 ui.warn(_("no open branch heads on branch %s\n") % branch) | |
1349 elif branch != branchrev: | |
1339 ui.warn(_("no changes on branch %s containing %s are " | 1350 ui.warn(_("no changes on branch %s containing %s are " |
1340 "reachable from %s\n") | 1351 "reachable from %s\n") |
1341 % (branch, branchrev, opts.get('rev'))) | 1352 % (branch, branchrev, opts.get('rev'))) |
1342 else: | 1353 else: |
1343 ui.warn(_("no changes on branch %s are reachable from %s\n") | 1354 ui.warn(_("no changes on branch %s are reachable from %s\n") |
3249 ('a', 'active', False, | 3260 ('a', 'active', False, |
3250 _('show only the active heads from open branches')), | 3261 _('show only the active heads from open branches')), |
3251 ('c', 'closed', False, | 3262 ('c', 'closed', False, |
3252 _('show normal and closed heads')), | 3263 _('show normal and closed heads')), |
3253 ] + templateopts, | 3264 ] + templateopts, |
3254 _('[-r REV] [REV]...')), | 3265 _('[-r STARTREV] [REV]...')), |
3255 "help": (help_, [], _('[TOPIC]')), | 3266 "help": (help_, [], _('[TOPIC]')), |
3256 "identify|id": | 3267 "identify|id": |
3257 (identify, | 3268 (identify, |
3258 [('r', 'rev', '', _('identify the specified revision')), | 3269 [('r', 'rev', '', _('identify the specified revision')), |
3259 ('n', 'num', None, _('show local revision number')), | 3270 ('n', 'num', None, _('show local revision number')), |