From patchwork Tue Feb 16 02:03:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4,of,5,RFC] wireproto: add "nonpublishing" wire protocol capability From: Gregory Szorc X-Patchwork-Id: 13221 Message-Id: <8b939990c70a4e545f18.1455588215@ubuntu-vm-main> To: mercurial-devel@mercurial-scm.org Date: Mon, 15 Feb 2016 18:03:35 -0800 # HG changeset patch # User Gregory Szorc # 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))