bookmarks: fix pushkey compatibility mode (
issue5777)
The namespace used for the compatibility mode was missing a trailing 's'.
--- a/mercurial/bundle2.py Tue Jan 30 20:32:48 2018 -0800
+++ b/mercurial/bundle2.py Tue Jan 30 22:27:45 2018 +0100
@@ -2033,7 +2033,7 @@
for book, node in changes:
hookargs = tr.hookargs.copy()
hookargs['pushkeycompat'] = '1'
- hookargs['namespace'] = 'bookmark'
+ hookargs['namespace'] = 'bookmarks'
hookargs['key'] = book
hookargs['old'] = nodemod.hex(bookstore.get(book, ''))
hookargs['new'] = nodemod.hex(node if node is not None else '')
--- a/tests/test-bookmarks-pushpull.t Tue Jan 30 20:32:48 2018 -0800
+++ b/tests/test-bookmarks-pushpull.t Tue Jan 30 22:27:45 2018 +0100
@@ -1173,3 +1173,72 @@
$ hg -R ../issue4455-dest/ bookmarks
no bookmarks set
+
+ $ cd ..
+
+Test that pre-pushkey compat for bookmark works as expected (issue5777)
+
+ $ cat << EOF >> $HGRCPATH
+ > [ui]
+ > ssh="$PYTHON" "$TESTDIR/dummyssh"
+ > [server]
+ > bookmarks-pushkey-compat = yes
+ > EOF
+
+ $ hg init server
+ $ echo foo > server/a
+ $ hg -R server book foo
+ $ hg -R server commit -Am a
+ adding a
+ $ hg clone ssh://user@dummy/server client
+ requesting all changes
+ adding changesets
+ adding manifests
+ adding file changes
+ added 1 changesets with 1 changes to 1 files
+ new changesets 79513d0d7716
+ updating to branch default
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+Forbid bookmark move on the server
+
+ $ cat << EOF >> server/.hg/hgrc
+ > [hooks]
+ > prepushkey.no-bm-move= echo \$HG_NAMESPACE | grep -v bookmarks
+ > EOF
+
+pushing changeset is okay
+
+ $ echo bar >> client/a
+ $ hg -R client commit -m b
+ $ hg -R client push
+ pushing to ssh://user@dummy/server
+ searching for changes
+ remote: adding changesets
+ remote: adding manifests
+ remote: adding file changes
+ remote: added 1 changesets with 1 changes to 1 files
+
+attempt to move the bookmark is rejected
+
+ $ hg -R client book foo -r .
+ moving bookmark 'foo' forward from 79513d0d7716
+
+#if b2-pushkey
+ $ hg -R client push
+ pushing to ssh://user@dummy/server
+ searching for changes
+ no changes found
+ remote: pushkey-abort: prepushkey.no-bm-move hook exited with status 1
+ abort: updating bookmark foo failed!
+ [255]
+#endif
+#if b2-binary
+ $ hg -R client push
+ pushing to ssh://user@dummy/server
+ searching for changes
+ no changes found
+ remote: prepushkey.no-bm-move hook exited with status 1
+ abort: push failed on remote
+ [255]
+#endif
--- a/tests/test-bundle2-exchange.t Tue Jan 30 20:32:48 2018 -0800
+++ b/tests/test-bundle2-exchange.t Tue Jan 30 22:27:45 2018 +0100
@@ -253,7 +253,7 @@
remote: added 1 changesets with 0 changes to 0 files (-1 heads)
remote: 1 new obsolescence markers
remote: pre-close-tip:eea13746799a public book_eea1
- remote: pushkey: lock state after "bookmark"
+ remote: pushkey: lock state after "bookmarks"
remote: lock: free
remote: wlock: free
remote: postclose-tip:eea13746799a public book_eea1
@@ -339,7 +339,7 @@
remote: added 1 changesets with 1 changes to 1 files
remote: 1 new obsolescence markers
remote: pre-close-tip:5fddd98957c8 draft book_5fdd
- remote: pushkey: lock state after "bookmark"
+ remote: pushkey: lock state after "bookmarks"
remote: lock: free
remote: wlock: free
remote: postclose-tip:5fddd98957c8 draft book_5fdd
@@ -390,7 +390,7 @@
remote: added 1 changesets with 1 changes to 1 files
remote: 1 new obsolescence markers
remote: pre-close-tip:32af7686d403 public book_32af
- remote: pushkey: lock state after "bookmark"
+ remote: pushkey: lock state after "bookmarks"
remote: lock: free
remote: wlock: free
remote: postclose-tip:32af7686d403 public book_32af
--- a/tests/test-hook.t Tue Jan 30 20:32:48 2018 -0800
+++ b/tests/test-hook.t Tue Jan 30 22:27:45 2018 +0100
@@ -244,7 +244,7 @@
no changes found
pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=push
pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_TXNNAME=push HG_URL=file:$TESTTMP/a
- pushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=pushkey HG_HOOKTYPE=pushkey HG_KEY=foo HG_NAMESPACE=bookmark HG_NEW=0000000000000000000000000000000000000000 HG_PUSHKEYCOMPAT=1 HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
+ pushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=pushkey HG_HOOKTYPE=pushkey HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_PUSHKEYCOMPAT=1 HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_TXNNAME=push HG_URL=file:$TESTTMP/a
exporting bookmark foo
[1]
@@ -281,7 +281,7 @@
listkeys hook: HG_HOOKNAME=listkeys HG_HOOKTYPE=listkeys HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
no changes found
pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=push
- prepushkey.forbid hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=baz HG_NAMESPACE=bookmark HG_NEW=0000000000000000000000000000000000000000 HG_PUSHKEYCOMPAT=1 HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
+ prepushkey.forbid hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_PUSHKEYCOMPAT=1 HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
abort: prepushkey hook exited with status 1
[255]
$ cd ../a