commit: note new branch heads rather than topological heads
authorMatt Mackall <mpm@selenic.com>
Thu, 13 May 2010 17:24:21 -0500
changeset 11173 5b48d819d5f9
parent 11172 e9226eb3af2a
child 11174 ba78a1bfbfd9
commit: note new branch heads rather than topological heads Move to using contexts while we're at it.
mercurial/commands.py
tests/test-bheads.out
tests/test-branch-option.out
tests/test-branches.out
tests/test-clone-update-order.out
tests/test-clone.out
tests/test-convert-datesort.out
tests/test-fetch.out
tests/test-issue619.out
tests/test-keyword.out
tests/test-log.out
tests/test-merge-default.out
tests/test-mq-safety.out
tests/test-newbranch.out
tests/test-patchbomb.out
tests/test-pull-branch.out
tests/test-push-warn.out
tests/test-rebase-keep-branch.out
tests/test-subrepo.out
--- a/mercurial/commands.py	Thu May 13 11:33:11 2010 -0500
+++ b/mercurial/commands.py	Thu May 13 17:24:21 2010 -0500
@@ -730,30 +730,29 @@
         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
--- a/tests/test-bheads.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-bheads.out	Thu May 13 17:24:21 2010 -0500
@@ -10,7 +10,6 @@
 =======
 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 ()
--- a/tests/test-branch-option.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-branch-option.out	Thu May 13 17:24:21 2010 -0500
@@ -2,7 +2,6 @@
 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
--- a/tests/test-branches.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-branches.out	Thu May 13 17:24:21 2010 -0500
@@ -3,7 +3,6 @@
 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
--- a/tests/test-clone-update-order.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-clone-update-order.out	Thu May 13 17:24:21 2010 -0500
@@ -4,11 +4,9 @@
 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
--- a/tests/test-clone.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-clone.out	Thu May 13 17:24:21 2010 -0500
@@ -66,7 +66,6 @@
 
 % add branch 'stable' to repo a for later tests
 marked working directory as branch stable
-created new head
 % tag ref2
 
 % updating back to ref2
--- a/tests/test-convert-datesort.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-convert-datesort.out	Thu May 13 17:24:21 2010 -0500
@@ -3,7 +3,6 @@
 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
--- a/tests/test-fetch.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-fetch.out	Thu May 13 17:24:21 2010 -0500
@@ -86,7 +86,6 @@
 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 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 @@
 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
--- a/tests/test-issue619.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-issue619.out	Thu May 13 17:24:21 2010 -0500
@@ -5,6 +5,7 @@
 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
--- a/tests/test-keyword.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-keyword.out	Thu May 13 17:24:21 2010 -0500
@@ -462,7 +462,6 @@
 % 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
--- a/tests/test-log.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-log.out	Thu May 13 17:24:21 2010 -0500
@@ -339,7 +339,6 @@
 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
--- a/tests/test-merge-default.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-merge-default.out	Thu May 13 17:24:21 2010 -0500
@@ -30,7 +30,6 @@
 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)
--- a/tests/test-mq-safety.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-mq-safety.out	Thu May 13 17:24:21 2010 -0500
@@ -19,9 +19,9 @@
 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
--- a/tests/test-newbranch.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-newbranch.out	Thu May 13 17:24:21 2010 -0500
@@ -4,6 +4,7 @@
 % 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 @@
 
 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 @@
 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 @@
 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
--- a/tests/test-patchbomb.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-patchbomb.out	Thu May 13 17:24:21 2010 -0500
@@ -1644,7 +1644,6 @@
 % 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.
--- a/tests/test-pull-branch.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-pull-branch.out	Thu May 13 17:24:21 2010 -0500
@@ -11,7 +11,6 @@
 % 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
--- a/tests/test-push-warn.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-push-warn.out	Thu May 13 17:24:21 2010 -0500
@@ -169,6 +169,7 @@
 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 @@
 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 @@
 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 @@
 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
 |
--- a/tests/test-rebase-keep-branch.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-rebase-keep-branch.out	Thu May 13 17:24:21 2010 -0500
@@ -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:
--- a/tests/test-subrepo.out	Thu May 13 11:33:11 2010 -0500
+++ b/tests/test-subrepo.out	Thu May 13 17:24:21 2010 -0500
@@ -90,6 +90,7 @@
  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 @@
 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 @@
 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