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

login
register
mail settings
Submitter Gregory Szorc
Date Feb. 16, 2016, 2:03 a.m.
Message ID <8b939990c70a4e545f18.1455588215@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/13221/
State Accepted
Headers show

Comments

Gregory Szorc - Feb. 16, 2016, 2:03 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@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.

Patch

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))