diff mercurial/exchange.py @ 35783:c97639ad6874

bundle2: specify what capabilities will be used for We currently assume there is a symmetric relationship of bundle2 capabilities between client and server. However, this may not always be the case. We need a bundle2 capability to advertise bundle2 streaming clone support on servers to differentiate it from the existing, legacy streaming clone support. However, servers may wish to disable streaming clone support. If bundle2 capabilities were the same between client and server, a client (which may also be a server) that has disabled streaming clone support would not be able to perform a streaming clone itself! This commit introduces a "role" argument to bundle2.getrepocaps() that explicitly defines the role being performed. This will allow us (and extensions) to alter bundle2 capabilities depending on the operation being performed. Differential Revision: https://phab.mercurial-scm.org/D1923
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 20 Jan 2018 13:54:36 -0800
parents 56c30b31afbe
children 08cc94dd3d3c
line wrap: on
line diff
--- a/mercurial/exchange.py	Sat Jan 20 15:43:02 2018 -0800
+++ b/mercurial/exchange.py	Sat Jan 20 13:54:36 2018 -0800
@@ -1015,7 +1015,8 @@
 
     # create reply capability
     capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo,
-                                                      allowpushback=pushback))
+                                                      allowpushback=pushback,
+                                                      role='client'))
     bundler.newpart('replycaps', data=capsblob)
     replyhandlers = []
     for partgenname in b2partsgenorder:
@@ -1448,7 +1449,7 @@
     """pull data using bundle2
 
     For now, the only supported data are changegroup."""
-    kwargs = {'bundlecaps': caps20to10(pullop.repo)}
+    kwargs = {'bundlecaps': caps20to10(pullop.repo, role='client')}
 
     # make ui easier to access
     ui = pullop.repo.ui
@@ -1680,10 +1681,10 @@
             pullop.repo.invalidatevolatilesets()
     return tr
 
-def caps20to10(repo):
+def caps20to10(repo, role):
     """return a set with appropriate options to use bundle20 during getbundle"""
     caps = {'HG20'}
-    capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo))
+    capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo, role=role))
     caps.add('bundle2=' + urlreq.quote(capsblob))
     return caps