Comments
Patch
@@ -1170,12 +1170,17 @@ capabilities = {'HG20': (),
'remote-changegroup': ('http', 'https'),
'hgtagsfnodes': (),
}
-def getrepocaps(repo, allowpushback=False):
+def getrepocaps(repo, allowpushback=False, client=False, server=False):
"""return the bundle2 capabilities for a given repo
Exists to allow extensions (like evolution) to mutate the capabilities.
+
+ The returned value is used for both servers advertising their capabilities
+ as well as clients advertising their capabilities to servers as part of
+ bundle2 requests. The ``client`` and ``server`` boolean args can be
+ set to indicate which "role" the capabilities list is being requested for.
"""
caps = capabilities.copy()
caps['changegroup'] = tuple(sorted(changegroup.packermap.keys()))
if obsolete.isenabled(repo, obsolete.exchangeopt):
@@ -641,9 +641,10 @@ def _pushbundle2(pushop):
and pushop.ui.configbool('experimental', 'bundle2.pushback'))
# create reply capability
capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo,
- allowpushback=pushback))
+ allowpushback=pushback,
+ client=True))
bundler.newpart('replycaps', data=capsblob)
replyhandlers = []
for partgenname in b2partsgenorder:
partgen = b2partsgenmapping[partgenname]
@@ -1246,9 +1247,9 @@ def _pullobsolete(pullop):
def caps20to10(repo):
"""return a set with appropriate options to use bundle20 during getbundle"""
caps = set(['HG20'])
- capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo))
+ capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo, client=True))
caps.add('bundle2=' + urllib.quote(capsblob))
return caps
# List of names of steps to perform for a bundle2 for getbundle, order matters.
@@ -335,9 +335,10 @@ class localrepository(object):
def _restrictcapabilities(self, caps):
if self.ui.configbool('experimental', 'bundle2-advertise', True):
caps = set(caps)
- capsblob = bundle2.encodecaps(bundle2.getrepocaps(self))
+ capsblob = bundle2.encodecaps(bundle2.getrepocaps(self,
+ client=True))
caps.add('bundle2=' + urllib.quote(capsblob))
return caps
def _applyopenerreqs(self):
@@ -574,9 +574,9 @@ def _capabilities(repo, proto):
# otherwise, add 'streamreqs' detailing our local revlog format
else:
caps.append('streamreqs=%s' % ','.join(requiredformats))
if repo.ui.configbool('experimental', 'bundle2-advertise', True):
- capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo))
+ capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo, server=True))
caps.append('bundle2=' + urllib.quote(capsblob))
caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
caps.append(
'httpheader=%d' % repo.ui.configint('server', 'maxhttpheaderlen', 1024))