phase: apply publishing enforcement for "serve" source
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 07 Apr 2014 18:10:50 -0700
changeset 20966 63659b809021
parent 20965 774ff56cbe34
child 20967 984850270acb
phase: apply publishing enforcement for "serve" source When a changegroup is added by a push on a publishing server, we ensure they are added as public. This is used to enforce publishing on server when the client is not aware of phases. It also prevents race conditions where a reader could see the changesets as draft before they get turned public by the client. Finally, this save rounds trip as the client does not need additional request to turn them public. However, this logic was only enforced when the changegroup was from a "push" source. And "push" is used for local pushes only. Wireprotocol push uses "serve" as source since Mercurial 1.9. We now enforce this logic for both "push" and "serve" sources. One could note that this logic was mainly useful during wireprotocol exchanges. So this code is finally put into good use, 9 versions after its introduction.
mercurial/changegroup.py
tests/test-http.t
tests/test-push-http.t
--- a/mercurial/changegroup.py	Thu Apr 10 12:41:39 2014 -0400
+++ b/mercurial/changegroup.py	Mon Apr 07 18:10:50 2014 -0700
@@ -677,7 +677,7 @@
 
         added = [cl.node(r) for r in xrange(clstart, clend)]
         publishing = repo.ui.configbool('phases', 'publish', True)
-        if srctype == 'push':
+        if srctype in ('push', 'serve'):
             # Old servers can not push the boundary themselves.
             # New servers won't push the boundary if changeset already
             # exists locally as secret
--- a/tests/test-http.t	Thu Apr 10 12:41:39 2014 -0400
+++ b/tests/test-http.t	Mon Apr 07 18:10:50 2014 -0700
@@ -267,7 +267,6 @@
   "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
   "POST /?cmd=unbundle HTTP/1.1" 200 - x-hgarg-1:heads=686173686564+5eb5abfefeea63c80dd7553bcc3783f37e0c5524
   "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases
-  "POST /?cmd=pushkey HTTP/1.1" 200 - x-hgarg-1:key=7f4e523d01f2cc3765ac8934da3d14db775ff872&namespace=phases&new=0&old=1
   "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
 
 #endif
--- a/tests/test-push-http.t	Thu Apr 10 12:41:39 2014 -0400
+++ b/tests/test-push-http.t	Mon Apr 07 18:10:50 2014 -0700
@@ -68,7 +68,6 @@
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
   remote: changegroup hook: HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_URL=remote:http:*: (glob)
-  remote: pushkey hook: HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_OLD=1 HG_RET=1
   % serve errors
   $ hg rollback
   repository tip rolled back to revision 0 (undo serve)
@@ -85,7 +84,6 @@
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
   remote: changegroup hook: HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_URL=remote:http:*: (glob)
-  remote: pushkey hook: HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_OLD=1 HG_RET=1
   % serve errors
   $ hg rollback
   repository tip rolled back to revision 0 (undo serve)
@@ -102,7 +100,6 @@
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
   remote: changegroup hook: HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_URL=remote:http:*: (glob)
-  remote: pushkey hook: HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_OLD=1 HG_RET=1
   % serve errors
   $ hg rollback
   repository tip rolled back to revision 0 (undo serve)
@@ -123,8 +120,6 @@
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
-  remote: prepushkey hook: HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_OLD=1
-  updating ba677d0156c1 to public failed!
   % serve errors
 
 expect phase change success
@@ -134,7 +129,6 @@
   pushing to http://localhost:$HGPORT/
   searching for changes
   no changes found
-  remote: prepushkey hook: HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_OLD=1
   % serve errors
   [1]
   $ hg rollback