[PATCH 4 of 5 RFC] wireproto: add "nonpublishing" wire protocol capability

Gregory Szorc gregory.szorc at gmail.com
Mon Feb 15 21:03:35 EST 2016


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1455586341 28800
#      Mon Feb 15 17:32:21 2016 -0800
# Node ID 8b939990c70a4e545f18db3338f7798f09a94ada
# Parent  3d322b59249c3ce7588691495684e9c554023119
wireproto: add "nonpublishing" wire protocol capability

Clients wishing to perform phase discovery via public phases heads
as opposed to draft phase roots need to query a separate namespace.

Unless the server advertises the existence of this namespace, clients
would have to waste a round trip to the server to know if the server
supports exposing public phase heads. We prevent this round trip by
introducing a server capability that informs clients that public
phase heads can be listed.

TODO advertising "nonpublishing" for the existence of "publicphases"
feels somewhat wrong.

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -626,16 +626,21 @@ def _capabilities(repo, proto):
         else:
             caps.append('streamreqs=%s' % ','.join(sorted(requiredformats)))
     if repo.ui.configbool('experimental', 'bundle2-advertise', True):
         capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo))
         caps.append('bundle2=' + urllib.quote(capsblob))
     caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
     caps.append(
         'httpheader=%d' % repo.ui.configint('server', 'maxhttpheaderlen', 1024))
+
+    if not repo.publishing():
+        # This implies support for the "publicphases" namespace.
+        caps.append('nonpublishing')
+
     return caps
 
 # If you are writing an extension and consider wrapping this function. Wrap
 # `_capabilities` instead.
 @wireprotocommand('capabilities')
 def capabilities(repo, proto):
     return ' '.join(_capabilities(repo, proto))
 


More information about the Mercurial-devel mailing list