Mercurial > hg
changeset 10350:fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Sat, 06 Feb 2010 19:38:39 +0100 |
parents | 20356e69710c |
children | 38fe86fb16e3 |
files | mercurial/commands.py tests/test-bheads tests/test-bheads.out tests/test-branches.out tests/test-bundle.out tests/test-clone.out tests/test-debugcomplete.out tests/test-url-rev.out |
diffstat | 8 files changed, 223 insertions(+), 115 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Sat Feb 06 19:33:40 2010 +0100 +++ b/mercurial/commands.py Sat Feb 06 19:38:39 2010 +0100 @@ -1388,27 +1388,24 @@ def heads(ui, repo, *branchrevs, **opts): """show current repository heads or show branch heads - With no arguments, show all repository head changesets. + With no arguments, show all repository branch heads. Repository "heads" are changesets with no child changesets. They are where development generally takes place and are the usual targets - for update and merge operations. - - If one or more REV is given, the "branch heads" will be shown for - the named branch associated with the specified changeset(s). - - Branch heads are changesets on a named branch with no descendants on - the same branch. A branch head could be a "true" (repository) head, - or it could be the last changeset on that branch before it was - merged into another branch, or it could be the last changeset on the - branch before a new branch was created. If none of the branch heads - are true heads, the branch is considered inactive. + for update and merge operations. Branch heads are changesets that have + no child changeset on the same branch. + + If one or more REVs are given, only branch heads on the branches + associated with the specified changesets are shown. If -c/--closed is specified, also show branch heads marked closed (see hg commit --close-branch). If STARTREV is specified, only those heads that are descendants of STARTREV will be displayed. + + If -t/--topo is specified, named branch mechanics will be ignored and only + changesets without children will be shown. """ if opts.get('rev'): @@ -1416,35 +1413,34 @@ else: start = None - closed = opts.get('closed') - if not branchrevs: - heads = repo.heads(start) - + if opts.get('topo'): + heads = [repo[h] for h in repo.heads(start)] else: - - decode, encode = encoding.fromlocal, encoding.tolocal heads = [] - branches = set(repo[decode(br)].branch() for br in branchrevs) for b, ls in repo.branchmap().iteritems(): - if b not in branches: - continue if start is None: - heads += ls + heads += [repo[h] for h in ls] continue startrev = repo.changelog.rev(start) descendants = set(repo.changelog.descendants(startrev)) descendants.add(startrev) - heads += [h for h in ls if repo.changelog.rev(h) in descendants] + rev = repo.changelog.rev + heads += [repo[h] for h in ls if rev(h) in descendants] + + if branchrevs: + decode, encode = encoding.fromlocal, encoding.tolocal + branches = set(repo[decode(br)].branch() for br in branchrevs) + heads = [h for h in heads if h.branch() in branches] if not opts.get('closed'): - heads = [h for h in heads if not repo[h].extra().get('close')] + heads = [h for h in heads if not h.extra().get('close')] if opts.get('active') and branchrevs: dagheads = repo.heads(start) - heads = [h for h in heads if h in dagheads] + heads = [h for h in heads if h.node() in dagheads] if branchrevs: - haveheads = set(repo[h].branch() for h in heads) + haveheads = set(h.branch() for h in heads) if branches - haveheads: headless = ', '.join(encode(b) for b in branches - haveheads) msg = _('no open branch heads found on branches %s') @@ -1455,7 +1451,7 @@ if not heads: return 1 - heads = sorted((repo[h] for h in heads), key=lambda x: -x.rev()) + heads = sorted(heads, key=lambda x: -x.rev()) displayer = cmdutil.show_changeset(ui, repo, opts) for ctx in heads: displayer.show(ctx) @@ -3499,6 +3495,7 @@ "heads": (heads, [('r', 'rev', '', _('show only heads which are descendants of REV')), + ('t', 'topo', False, _('show topological heads only')), ('a', 'active', False, _('show active branchheads only [DEPRECATED]')), ('c', 'closed', False,
--- a/tests/test-bheads Sat Feb 06 19:33:40 2010 +0100 +++ b/tests/test-bheads Sat Feb 06 19:38:39 2010 +0100 @@ -2,7 +2,7 @@ heads() { - hg heads --template '{rev}: {desc|firstline|strip}\n' "$@" + hg heads --template '{rev}: {desc|firstline|strip} ({branches})\n' "$@" } hg init a @@ -111,3 +111,6 @@ echo '=======' heads 0 1 2 3 4 5 6 7 + +echo '% topological heads' +heads -t
--- a/tests/test-bheads.out Sat Feb 06 19:33:40 2010 +0100 +++ b/tests/test-bheads.out Sat Feb 06 19:38:39 2010 +0100 @@ -1,154 +1,182 @@ -0: Adding root node +0: Adding root node () ------- -0: Adding root node +0: Adding root node () ======= marked working directory as branch a -1: Adding a branch +1: Adding a branch (a) +0: Adding root node () ------- -1: Adding a branch +1: Adding a branch (a) ======= 0 files updated, 0 files merged, 1 files removed, 0 files unresolved marked working directory as branch b created new head -2: Adding b branch -1: Adding a branch +2: Adding b branch (b) +1: Adding a branch (a) +0: Adding root node () ------- -2: Adding b branch +2: Adding b branch (b) ======= -3: Adding b branch head 1 -1: Adding a branch +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () ------- -3: Adding b branch head 1 +3: Adding b branch head 1 (b) ======= 0 files updated, 0 files merged, 1 files removed, 0 files unresolved created new head -4: Adding b branch head 2 -3: Adding b branch head 1 -1: Adding a branch +4: Adding b branch head 2 (b) +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () ------- -4: Adding b branch head 2 -3: Adding b branch head 1 +4: Adding b branch head 2 (b) +3: Adding b branch head 1 (b) ======= 0 files updated, 0 files merged, 1 files removed, 0 files unresolved created new head -5: Adding b branch head 3 -4: Adding b branch head 2 -3: Adding b branch head 1 -1: Adding a branch +5: Adding b branch head 3 (b) +4: Adding b branch head 2 (b) +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () ------- -5: Adding b branch head 3 -4: Adding b branch head 2 -3: Adding b branch head 1 +5: Adding b branch head 3 (b) +4: Adding b branch head 2 (b) +3: Adding b branch head 1 (b) ======= 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) -6: Merging b branch head 2 and b branch head 3 -3: Adding b branch head 1 -1: Adding a branch +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () ------- -6: Merging b branch head 2 and b branch head 3 -3: Adding b branch head 1 +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) ======= marked working directory as branch c -7: Adding c branch -3: Adding b branch head 1 -1: Adding a branch +7: Adding c branch (c) +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () ------- -7: Adding c branch +7: Adding c branch (c) ======= no open branch heads found on branches c (started at 3) 1 ------- -7: Adding c branch +7: Adding c branch (c) 0 ------- 0 files updated, 0 files merged, 2 files removed, 0 files unresolved 0 ------- -3: Adding b branch head 1 +3: Adding b branch head 1 (b) 0 ------- -6: Merging b branch head 2 and b branch head 3 -3: Adding b branch head 1 +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) 0 ------- no open branch heads found on branches b (started at 7) 1 ======= 0 files updated, 0 files merged, 2 files removed, 0 files unresolved -7: Adding c branch -3: Adding b branch head 1 -1: Adding a branch +7: Adding c branch (c) +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () ------- -0: Adding root node +0: Adding root node () ------- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved -7: Adding c branch -3: Adding b branch head 1 -1: Adding a branch +7: Adding c branch (c) +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () ------- -1: Adding a branch +1: Adding a branch (a) ------- 1 files updated, 0 files merged, 1 files removed, 0 files unresolved -7: Adding c branch -3: Adding b branch head 1 -1: Adding a branch +7: Adding c branch (c) +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () ------- -6: Merging b branch head 2 and b branch head 3 -3: Adding b branch head 1 +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) ------- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved -7: Adding c branch -3: Adding b branch head 1 -1: Adding a branch +7: Adding c branch (c) +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () ------- -6: Merging b branch head 2 and b branch head 3 -3: Adding b branch head 1 +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) ------- 1 files updated, 0 files merged, 1 files removed, 0 files unresolved -7: Adding c branch -3: Adding b branch head 1 -1: Adding a branch +7: Adding c branch (c) +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () ------- -6: Merging b branch head 2 and b branch head 3 -3: Adding b branch head 1 +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) ------- 1 files updated, 0 files merged, 1 files removed, 0 files unresolved -7: Adding c branch -3: Adding b branch head 1 -1: Adding a branch +7: Adding c branch (c) +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () ------- -6: Merging b branch head 2 and b branch head 3 -3: Adding b branch head 1 +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) ------- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved -7: Adding c branch -3: Adding b branch head 1 -1: Adding a branch +7: Adding c branch (c) +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () ------- -6: Merging b branch head 2 and b branch head 3 -3: Adding b branch head 1 +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) ------- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved -7: Adding c branch -3: Adding b branch head 1 -1: Adding a branch +7: Adding c branch (c) +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () ------- -7: Adding c branch +7: Adding c branch (c) ------- ======= -1: Adding a branch +1: Adding a branch (a) ------- -6: Merging b branch head 2 and b branch head 3 -3: Adding b branch head 1 +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) ------- -7: Adding c branch +7: Adding c branch (c) ------- abort: unknown revision 'z'! ------- ======= -7: Adding c branch -6: Merging b branch head 2 and b branch head 3 -3: Adding b branch head 1 -1: Adding a branch -0: Adding root node +7: Adding c branch (c) +6: Merging b branch head 2 and b branch head 3 (b) +3: Adding b branch head 1 (b) +1: Adding a branch (a) +0: Adding root node () +% topological heads +7: Adding c branch (c) +3: Adding b branch head 1 (b) +1: Adding a branch (a)
--- a/tests/test-branches.out Sat Feb 06 19:33:40 2010 +0100 +++ b/tests/test-branches.out Sat Feb 06 19:38:39 2010 +0100 @@ -83,6 +83,24 @@ date: Thu Jan 01 00:00:06 1970 +0000 summary: Adding d branch +changeset: 6:589736a22561 +branch: c +user: test +date: Thu Jan 01 00:00:05 1970 +0000 +summary: Adding c branch + +changeset: 5:d8cbc61dbaa6 +branch: a +parent: 2:881fe2b92ad0 +user: test +date: Thu Jan 01 00:00:04 1970 +0000 +summary: Adding b branch head 2 + +changeset: 0:19709c5a4e75 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: Adding root node + changeset: 10:bfbe841b666e branch: b tag: tip @@ -103,6 +121,24 @@ date: Thu Jan 01 00:00:06 1970 +0000 summary: Adding d branch +changeset: 6:589736a22561 +branch: c +user: test +date: Thu Jan 01 00:00:05 1970 +0000 +summary: Adding c branch + +changeset: 5:d8cbc61dbaa6 +branch: a +parent: 2:881fe2b92ad0 +user: test +date: Thu Jan 01 00:00:04 1970 +0000 +summary: Adding b branch head 2 + +changeset: 0:19709c5a4e75 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: Adding root node + b 8:eebb944467c9 a branch name much longer than the default justification used by branches 7:10ff5895aa57 1 files updated, 0 files merged, 0 files removed, 0 files unresolved @@ -149,6 +185,24 @@ date: Thu Jan 01 00:00:06 1970 +0000 summary: Adding d branch +changeset: 6:589736a22561 +branch: c +user: test +date: Thu Jan 01 00:00:05 1970 +0000 +summary: Adding c branch + +changeset: 5:d8cbc61dbaa6 +branch: a +parent: 2:881fe2b92ad0 +user: test +date: Thu Jan 01 00:00:04 1970 +0000 +summary: Adding b branch head 2 + +changeset: 0:19709c5a4e75 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: Adding root node + % branch default changeset: 0:19709c5a4e75 user: test
--- a/tests/test-bundle.out Sat Feb 06 19:33:40 2010 +0100 +++ b/tests/test-bundle.out Sat Feb 06 19:38:39 2010 +0100 @@ -19,11 +19,6 @@ added 0 changesets with 0 changes to 4 files (run 'hg update' to get a working copy) ====== Verify empty -changeset: -1:000000000000 -tag: tip -user: -date: Thu Jan 01 00:00:00 1970 +0000 - checking changesets checking manifests crosschecking files in changesets and manifests
--- a/tests/test-clone.out Sat Feb 06 19:33:40 2010 +0100 +++ b/tests/test-clone.out Sat Feb 06 19:38:39 2010 +0100 @@ -217,6 +217,11 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: another change for branch stable +changeset: 10:a7949464abda +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: test + % same revision checked out in repo a and ua e8ece76546a6 @@ -239,6 +244,11 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: another change for branch stable +changeset: 10:a7949464abda +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: test + % same revision checked out in repo a and ua e8ece76546a6 @@ -261,6 +271,11 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: another change for branch stable +changeset: 10:a7949464abda +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: test + % branch stable is checked out changeset: 13:0aae7cf88f0d
--- a/tests/test-debugcomplete.out Sat Feb 06 19:33:40 2010 +0100 +++ b/tests/test-debugcomplete.out Sat Feb 06 19:38:39 2010 +0100 @@ -206,7 +206,7 @@ debugsub: rev debugwalk: include, exclude grep: print0, all, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude -heads: rev, active, closed, style, template +heads: rev, topo, active, closed, style, template help: identify: rev, num, id, branch, tags import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity
--- a/tests/test-url-rev.out Sat Feb 06 19:33:40 2010 +0100 +++ b/tests/test-url-rev.out Sat Feb 06 19:38:39 2010 +0100 @@ -15,6 +15,11 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: change a +changeset: 0:1f0dee641bb7 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: add a + % parents changeset: 1:cd2a86ecc814 branch: foo @@ -63,6 +68,11 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: new head of branch foo +changeset: 0:1f0dee641bb7 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: add a + % rolling back rolling back last transaction @@ -76,6 +86,11 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: new head of branch foo +changeset: 0:1f0dee641bb7 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: add a + % pull should not have updated 1:cd2a86ecc814 @@ -107,6 +122,7 @@ 0:1f0dee641bb7 % heads 1:cd2a86ecc814 +0:1f0dee641bb7 % pull -u -r otherrev url#rev updates to rev % parents changeset: 3:4cd725637392