# HG changeset patch # User Matt Mackall # Date 2010-05-13 22:24:21 # Node ID 5b48d819d5f93f0f093568442053b8638f9dc7ab # Parent e9226eb3af2a90cd21bdf6fdf98836b8dfa257ef commit: note new branch heads rather than topological heads Move to using contexts while we're at it. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -730,30 +730,29 @@ def commit(ui, repo, *pats, **opts): return repo.commit(message, opts.get('user'), opts.get('date'), match, editor=e, extra=extra) + branch = repo[None].branch() + bheads = repo.branchheads(branch) + node = cmdutil.commit(ui, repo, commitfunc, pats, opts) if not node: ui.status(_("nothing changed\n")) return - cl = repo.changelog - rev = cl.rev(node) - parents = cl.parentrevs(rev) - if rev - 1 in parents: - # one of the parents was the old tip - pass - elif (parents == (nullrev, nullrev) or - len(cl.heads(cl.node(parents[0]))) > 1 and - (parents[1] == nullrev or len(cl.heads(cl.node(parents[1]))) > 1)): + + ctx = repo[node] + parents = ctx.parents() + + if bheads and [x for x in parents if x.node() not in bheads]: ui.status(_('created new head\n')) if not opts.get('close_branch'): for r in parents: - if repo[r].extra().get('close'): + if r.extra().get('close'): ui.status(_('reopening closed branch head %d\n') % r) if ui.debugflag: - ui.write(_('committed changeset %d:%s\n') % (rev, hex(node))) + ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex())) elif ui.verbose: - ui.write(_('committed changeset %d:%s\n') % (rev, short(node))) + ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx)) def copy(ui, repo, *pats, **opts): """mark files as copied for the next commit diff --git a/tests/test-bheads.out b/tests/test-bheads.out --- a/tests/test-bheads.out +++ b/tests/test-bheads.out @@ -10,7 +10,6 @@ 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 (b) 1: Adding a branch (a) 0: Adding root node () diff --git a/tests/test-branch-option.out b/tests/test-branch-option.out --- a/tests/test-branch-option.out +++ b/tests/test-branch-option.out @@ -2,7 +2,6 @@ marked working directory as branch a adding foo 1 files updated, 0 files merged, 0 files removed, 0 files unresolved marked working directory as branch c -created new head requesting all changes adding changesets adding manifests diff --git a/tests/test-branches.out b/tests/test-branches.out --- a/tests/test-branches.out +++ b/tests/test-branches.out @@ -3,7 +3,6 @@ marked working directory as branch q reset working directory to branch a 0 files updated, 0 files merged, 1 files removed, 0 files unresolved marked working directory as branch b -created new head 1 files updated, 0 files merged, 2 files removed, 0 files unresolved marked working directory as branch c abort: the name 'tip' is reserved diff --git a/tests/test-clone-update-order.out b/tests/test-clone-update-order.out --- a/tests/test-clone-update-order.out +++ b/tests/test-clone-update-order.out @@ -4,11 +4,9 @@ adding bar 0 files updated, 0 files merged, 1 files removed, 0 files unresolved marked working directory as branch mine adding world -created new head 0 files updated, 0 files merged, 1 files removed, 0 files unresolved marked working directory as branch other adding bye -created new head 1 files updated, 0 files merged, 1 files removed, 0 files unresolved % test -U -u abort: cannot specify both --noupdate and --updaterev diff --git a/tests/test-clone.out b/tests/test-clone.out --- a/tests/test-clone.out +++ b/tests/test-clone.out @@ -66,7 +66,6 @@ 1 files updated, 0 files merged, 1 files % add branch 'stable' to repo a for later tests marked working directory as branch stable -created new head % tag ref2 % updating back to ref2 diff --git a/tests/test-convert-datesort.out b/tests/test-convert-datesort.out --- a/tests/test-convert-datesort.out +++ b/tests/test-convert-datesort.out @@ -3,7 +3,6 @@ marked working directory as branch branc 1 files updated, 0 files merged, 0 files removed, 0 files unresolved marked working directory as branch branchb adding b -created new head 1 files updated, 0 files merged, 1 files removed, 0 files unresolved 2 files updated, 0 files merged, 0 files removed, 0 files unresolved % convert with datesort diff --git a/tests/test-fetch.out b/tests/test-fetch.out --- a/tests/test-fetch.out +++ b/tests/test-fetch.out @@ -86,7 +86,6 @@ marked working directory as branch a 1 files updated, 0 files merged, 0 files removed, 0 files unresolved marked working directory as branch b adding b -created new head % pull in change on foreign branch updating to branch default @@ -156,8 +155,8 @@ 1 files updated, 0 files merged, 0 files 1 files updated, 0 files merged, 0 files removed, 0 files unresolved 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) +created new head 1 files updated, 0 files merged, 0 files removed, 0 files unresolved -created new head 1 files updated, 0 files merged, 0 files removed, 0 files unresolved created new head 1 files updated, 0 files merged, 0 files removed, 0 files unresolved @@ -184,6 +183,7 @@ marked working directory as branch secon adding b marked working directory as branch default adding c +created new head updating to branch default 3 files updated, 0 files merged, 0 files removed, 0 files unresolved % fetch should succeed diff --git a/tests/test-issue619.out b/tests/test-issue619.out --- a/tests/test-issue619.out +++ b/tests/test-issue619.out @@ -5,6 +5,7 @@ 0 files updated, 0 files merged, 1 files fast-forward 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) +created new head bogus fast-forward should fail abort: can't merge with ancestor done diff --git a/tests/test-keyword.out b/tests/test-keyword.out --- a/tests/test-keyword.out +++ b/tests/test-keyword.out @@ -462,7 +462,6 @@ bar % test restricted mode with transplant -b 1 files updated, 0 files merged, 0 files removed, 0 files unresolved marked working directory as branch foo -created new head 2 files updated, 0 files merged, 0 files removed, 0 files unresolved applying 4aa30d025d50 4aa30d025d50 transplanted to 5a4da427c162 diff --git a/tests/test-log.out b/tests/test-log.out --- a/tests/test-log.out +++ b/tests/test-log.out @@ -339,7 +339,6 @@ marked working directory as branch test adding b 0 files updated, 0 files merged, 1 files removed, 0 files unresolved adding c -created new head 1 files updated, 0 files merged, 1 files removed, 0 files unresolved adding c % log -b default diff --git a/tests/test-merge-default.out b/tests/test-merge-default.out --- a/tests/test-merge-default.out +++ b/tests/test-merge-default.out @@ -30,7 +30,6 @@ 1 files updated, 0 files merged, 0 files abort: there is nothing to merge - use "hg update" instead 1 files updated, 0 files merged, 0 files removed, 0 files unresolved marked working directory as branch foobranch -created new head % should fail because merge with other branch abort: branch 'foobranch' has one head - please merge with an explicit rev (run 'hg heads' to see all heads) diff --git a/tests/test-mq-safety.out b/tests/test-mq-safety.out --- a/tests/test-mq-safety.out +++ b/tests/test-mq-safety.out @@ -19,9 +19,9 @@ adding a 0 files updated, 0 files merged, 1 files removed, 0 files unresolved marked working directory as branch b adding c -created new head 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) +created new head 0 files updated, 0 files merged, 1 files removed, 0 files unresolved changeset: 2:65309210bf4e branch: b diff --git a/tests/test-newbranch.out b/tests/test-newbranch.out --- a/tests/test-newbranch.out +++ b/tests/test-newbranch.out @@ -4,6 +4,7 @@ marked working directory as branch bar % branch shadowing abort: a branch of the same name already exists (use 'hg update' to switch to it) marked working directory as branch default +created new head % there should be only one default branch head changeset: 3:bf1bc2f45e83 tag: tip @@ -13,10 +14,10 @@ summary: clear branch name 0 files updated, 0 files merged, 0 files removed, 0 files unresolved foo -created new head 0 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) foo +created new head changeset: 5:5f8fb06e083e branch: foo tag: tip @@ -112,6 +113,7 @@ 0 files updated, 0 files merged, 1 files 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) foo +created new head changeset: 6:f0c74f92a385 branch: foo tag: tip @@ -135,7 +137,6 @@ created new head 0 files updated, 0 files merged, 1 files removed, 0 files unresolved marked working directory as branch test adding e -created new head changeset: 4:3a1e01ed1df4 branch: test tag: tip diff --git a/tests/test-patchbomb.out b/tests/test-patchbomb.out --- a/tests/test-patchbomb.out +++ b/tests/test-patchbomb.out @@ -1644,7 +1644,6 @@ diff -r 000000000000 -r 8580ff50825a a % test outgoing 0 files updated, 0 files merged, 6 files removed, 0 files unresolved marked working directory as branch test -created new head comparing with ../t searching for changes This patch series consists of 8 patches. diff --git a/tests/test-pull-branch.out b/tests/test-pull-branch.out --- a/tests/test-pull-branch.out +++ b/tests/test-pull-branch.out @@ -11,7 +11,6 @@ 1 files updated, 0 files merged, 0 files % create branch B 1 files updated, 0 files merged, 0 files removed, 0 files unresolved marked working directory as branch branchB -created new head % a new branch is there pulling from ../t searching for changes diff --git a/tests/test-push-warn.out b/tests/test-push-warn.out --- a/tests/test-push-warn.out +++ b/tests/test-push-warn.out @@ -169,6 +169,7 @@ marked working directory as branch b 1 files updated, 0 files merged, 0 files removed, 0 files unresolved 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) +created new head pushing to j searching for changes abort: push creates new remote branches: b! @@ -190,7 +191,6 @@ 0 files updated, 0 files merged, 0 files adding b1 0 files updated, 0 files merged, 1 files removed, 0 files unresolved adding a2 -created new head %% glog of local @ 2: A a2 | @@ -222,7 +222,6 @@ marked working directory as branch B adding b 0 files updated, 0 files merged, 1 files removed, 0 files unresolved adding a1 -created new head updating to branch A 2 files updated, 0 files merged, 0 files removed, 0 files unresolved 1 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -263,13 +262,14 @@ adding a 0 files updated, 0 files merged, 1 files removed, 0 files unresolved marked working directory as branch B adding b -created new head updating to branch B 1 files updated, 0 files merged, 0 files removed, 0 files unresolved 1 files updated, 0 files merged, 1 files removed, 0 files unresolved marked working directory as branch B +created new head 1 files updated, 0 files merged, 1 files removed, 0 files unresolved marked working directory as branch A +created new head %% glog of local @ 5: A b3 | diff --git a/tests/test-rebase-keep-branch.out b/tests/test-rebase-keep-branch.out --- a/tests/test-rebase-keep-branch.out +++ b/tests/test-rebase-keep-branch.out @@ -1,6 +1,5 @@ 0 files updated, 0 files merged, 2 files removed, 0 files unresolved marked working directory as branch notdefault -created new head @ 4:r1:notdefault | | o 3:l2: diff --git a/tests/test-subrepo.out b/tests/test-subrepo.out --- a/tests/test-subrepo.out +++ b/tests/test-subrepo.out @@ -90,6 +90,7 @@ path t source t revision 6747d179aa9a688023c4b0cad32e4c92bb7f34ad committing subrepository t +created new head searching for copies back to rev 2 resolving manifests overwrite None partial False @@ -222,16 +223,16 @@ adding a marked working directory as branch br 1 files updated, 0 files merged, 0 files removed, 0 files unresolved adding b -created new head 1 files updated, 0 files merged, 1 files removed, 0 files unresolved 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) +created new head 1 files updated, 0 files merged, 0 files removed, 0 files unresolved adding c -created new head 1 files updated, 0 files merged, 1 files removed, 0 files unresolved 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) +created new head 1 files updated, 0 files merged, 1 files removed, 0 files unresolved adding .hgsub committing subrepository s @@ -241,15 +242,14 @@ adding b committing subrepository s 1 files updated, 0 files merged, 1 files removed, 0 files unresolved adding c -created new head 2 files updated, 0 files merged, 1 files removed, 0 files unresolved 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) +created new head 1 files updated, 0 files merged, 1 files removed, 0 files unresolved 1 files updated, 0 files merged, 0 files removed, 0 files unresolved adding d committing subrepository s -created new head 2 files updated, 0 files merged, 1 files removed, 0 files unresolved 1 files updated, 0 files merged, 0 files removed, 0 files unresolved adding e