D6847: dont-accept-this: this is for reference in D6776

valentin.gatienbaron (Valentin Gatien-Baron) phabricator at mercurial-scm.org
Fri Sep 13 04:25:40 UTC 2019


valentin.gatienbaron created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6847

AFFECTED FILES
  mercurial/exchange.py
  tests/test-bookflow.t
  tests/test-bookmarks-conflict.t
  tests/test-bookmarks-pushpull.t

CHANGE DETAILS

diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -816,7 +816,7 @@
      Z                         0d2164f0ce0d
      foo                                   
      foobar                                
-  $ hg push -B Z http://localhost:$HGPORT/
+  $ hg push -f -B Z http://localhost:$HGPORT/
   pushing to http://localhost:$HGPORT/
   searching for changes
   no changes found
@@ -1041,9 +1041,8 @@
   $ hg push -B X
   pushing to $TESTTMP/addmarks
   searching for changes
-  remote has heads on branch 'default' that are not known locally: a2a606d9ff1b
-  abort: push creates new remote head 54694f811df9 with bookmark 'X'!
-  (pull and merge or see 'hg help push' for details about pushing new heads)
+  abort: push rejected: bookmark "X" has changed
+  (run 'hg pull', resolve conflicts, and push again)
   [255]
   $ cd ../addmarks
 
diff --git a/tests/test-bookmarks-conflict.t b/tests/test-bookmarks-conflict.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookmarks-conflict.t
@@ -0,0 +1,90 @@
+initialize
+  $ make_changes() {
+  >     d=`pwd`
+  >     [ ! -z $1 ] && cd $1
+  >     echo "test `basename \`pwd\``" >> test
+  >     hg commit -Am"${2:-test}"
+  >     r=$?
+  >     cd $d
+  >     return $r
+  > }
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+  $ hg book @
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_b
+
+clone to c
+  $ mkdir ../c
+  $ cd ../c
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_c
+
+push from b
+  $ cd ../b
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  updating bookmark @
+  exporting bookmark bk_b
+  $ hg -R ../a id -r @
+  e11a942451be tip @/bk_b
+
+push from c
+  $ cd ../c
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  remote has heads on branch 'default' that are not known locally: e11a942451be
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+  exporting bookmark bk_c
+  $ hg push -B @
+  pushing to $TESTTMP/a
+  searching for changes
+  abort: push rejected: bookmark "@" has changed
+  (run 'hg pull', resolve conflicts, and push again)
+  [255]
+  $ hg -R ../a log -G -T '{rev} {bookmarks}'
+  o  2 bk_c
+  |
+  | o  1 @ bk_b
+  |/
+  @  0
+  
+
+  $ hg push -B @ --force
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  updating bookmark @
+  [1]
+  $ hg -R ../a log -G -T '{rev} {bookmarks}'
+  o  2 @ bk_c
+  |
+  | o  1 bk_b
+  |/
+  @  0
+  
diff --git a/tests/test-bookflow.t b/tests/test-bookflow.t
--- a/tests/test-bookflow.t
+++ b/tests/test-bookflow.t
@@ -140,8 +140,8 @@
   $ cd ../b
   $ # make sure we cannot push after bookmarks diverged
   $ hg push -B X | grep abort
-  abort: push creates new remote head * with bookmark 'X'! (glob)
-  (pull and merge or see 'hg help push' for details about pushing new heads)
+  abort: push rejected: bookmark "X" has changed
+  (run 'hg pull', resolve conflicts, and push again)
   [1]
   $ hg pull -u | grep divergent
   divergent bookmark X stored as X at default
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -739,7 +739,12 @@
     for b, scid, dcid in list(advdst) + list(diverge) + list(differ):
         if b in explicit:
             explicit.remove(b)
-            pushop.outbookmarks.append((b, dcid, scid))
+            if pushop.force:
+                pushop.outbookmarks.append((b, dcid, scid))
+            else:
+                msg = _('push rejected: bookmark "%s" has changed') % b
+                hint = _("run 'hg pull', resolve conflicts, and push again")
+                raise error.Abort(msg, hint=hint)
     # search for bookmark to delete
     for b, scid, dcid in adddst:
         if b in explicit:



To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list