changeset 36243:c19e66dacaa1 stable

tests: expand test coverage for updating phases Consolidating the tests demonstrated that there are behavior differences when pushing phases between bundle1 and bundle2. A reason for this is the behavior of legacy pushes where the client queries the state of phases and then conditionally updates phases after an "unbundle" is processed. This behavior is expected. The tests were incomplete because they only tested the case of a publishing repo. In this commit, we add a variant for a non-publishing repo. We still see some differences between the legacy and bundle2 exchanges. But they are less pronounced. The behavior of not firing a pushkey hook when phases are updated as part of changegroup application feels weird to me. I'm not sure if this is a feature or a bug. By the time the "pushkey" or "phases" bundle2 part is applied, the phases have already been moved on a publishing repository. We fire the "pushkey" hook regardless, even though it would be a no-op. This is the part that feels the most buggy.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 18 Feb 2018 16:19:26 -0800
parents 477280637646
children 579c28576ba5 eedc69d2776d 2c647da851ed
files tests/test-push-http.t
diffstat 1 files changed, 78 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-push-http.t	Sun Feb 18 10:00:34 2018 -0800
+++ b/tests/test-push-http.t	Sun Feb 18 16:19:26 2018 -0800
@@ -162,7 +162,7 @@
   repository tip rolled back to revision 0 (undo serve)
   $ mv $HGRCPATH.orig $HGRCPATH
 
-expect push success, phase change failure
+Test pushing to a publishing repository with a failing prepushkey hook
 
   $ cat > .hg/hgrc <<EOF
   > [web]
@@ -175,6 +175,10 @@
   > EOF
 
 #if bundle1
+Bundle1 works because a) phases are updated as part of changegroup application
+and b) client checks phases after the "unbundle" command. Since it sees no
+phase changes are necessary, it doesn't send the "pushkey" command and the
+prepushkey hook never has to fire.
 
   $ req
   pushing to http://localhost:$HGPORT/
@@ -188,7 +192,8 @@
 #endif
 
 #if bundle2
-
+Bundle2 sends a "pushkey" bundle2 part. This runs as part of the transaction
+and fails the entire push.
   $ req
   pushing to http://localhost:$HGPORT/
   searching for changes
@@ -206,30 +211,40 @@
 
 #endif
 
-expect phase change success
+Now remove the failing prepushkey hook.
 
   $ cat >> .hg/hgrc <<EOF
   > [hooks]
   > prepushkey = sh -c "printenv.py prepushkey 0"
-  > [devel]
-  > legacy.exchange=
   > EOF
 
-#if bundle1
+We don't need to test bundle1 because it succeeded above.
 
+#if bundle2
   $ req
   pushing to http://localhost:$HGPORT/
   searching for changes
-  no changes found
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
   % serve errors
-  [1]
-  $ hg rollback
-  repository tip rolled back to revision 0 (undo serve)
-
 #endif
 
-#if bundle2
+  $ hg --config extensions.strip= strip -r 1:
+  saved backup bundle to $TESTTMP/test/.hg/strip-backup/ba677d0156c1-eea704d7-backup.hg
+
+Now do a variant of the above, except on a non-publishing repository
 
+  $ cat >> .hg/hgrc <<EOF
+  > [phases]
+  > publish = false
+  > [hooks]
+  > prepushkey = sh -c "printenv.py prepushkey 1"
+  > EOF
+
+#if bundle1
   $ req
   pushing to http://localhost:$HGPORT/
   searching for changes
@@ -237,12 +252,61 @@
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
+  remote: prepushkey hook: HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_OLD=1
+  remote: pushkey-abort: prepushkey hook exited with status 1
+  updating ba677d0156c1 to public failed!
   % serve errors
-  $ hg rollback
-  repository tip rolled back to revision 0 (undo serve)
+#endif
+
+#if bundle2
+  $ req
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
+  remote: pushkey-abort: prepushkey hook exited with status 1
+  remote: transaction abort!
+  remote: rollback completed
+  abort: updating ba677d0156c1 to public failed
+  % serve errors
+  [255]
+#endif
+
+Make phases updates work
 
+  $ cat >> .hg/hgrc <<EOF
+  > [hooks]
+  > prepushkey = sh -c "printenv.py prepushkey 0"
+  > EOF
+
+#if bundle1
+  $ req
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+  remote: prepushkey hook: HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_OLD=1
+  % serve errors
+  [1]
 #endif
 
+#if bundle2
+  $ req
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
+  % serve errors
+#endif
+
+  $ hg --config extensions.strip= strip -r 1:
+  saved backup bundle to $TESTTMP/test/.hg/strip-backup/ba677d0156c1-eea704d7-backup.hg
+
 expect authorization error: all users denied
 
   $ echo '[web]' > .hg/hgrc