bundle2: introduce a `getrepocaps` to retrieve the bundle2 caps of a repo
This function lets extensions change the bundle2 capabilities of a repository.
--- a/mercurial/bundle2.py Mon Aug 25 19:17:06 2014 +0200
+++ b/mercurial/bundle2.py Mon Aug 25 19:21:47 2014 +0200
@@ -781,6 +781,14 @@
'b2x:changegroup': (),
}
+def getrepocaps(repo):
+ """return the bundle2 capabilities for a given repo
+
+ Exists to allow extensions (like evolution) to mutate the
+ capabilities.
+ """
+ return capabilities
+
def bundle2caps(remote):
"""return the bundlecapabilities of a peer as dict"""
raw = remote.capable('bundle2-exp')
--- a/mercurial/exchange.py Mon Aug 25 19:17:06 2014 +0200
+++ b/mercurial/exchange.py Mon Aug 25 19:21:47 2014 +0200
@@ -465,7 +465,7 @@
evolve in the future."""
bundler = bundle2.bundle20(pushop.ui, bundle2.bundle2caps(pushop.remote))
# create reply capability
- capsblob = bundle2.encodecaps(bundle2.capabilities)
+ capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo))
bundler.newpart('b2x:replycaps', data=capsblob)
replyhandlers = []
for partgenname in b2partsgenorder:
@@ -588,7 +588,7 @@
#
# This will eventually be unified with the changesets bundle2 push
bundler = bundle2.bundle20(pushop.ui, b2caps)
- capsblob = bundle2.encodecaps(pushop.repo.bundle2caps)
+ capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo))
bundler.newpart('b2x:replycaps', data=capsblob)
part2node = []
enc = pushkey.encode
@@ -922,7 +922,7 @@
def caps20to10(repo):
"""return a set with appropriate options to use bundle20 during getbundle"""
caps = set(['HG2X'])
- capsblob = bundle2.encodecaps(bundle2.capabilities)
+ capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo))
caps.add('bundle2=' + urllib.quote(capsblob))
return caps
--- a/mercurial/localrepo.py Mon Aug 25 19:17:06 2014 +0200
+++ b/mercurial/localrepo.py Mon Aug 25 19:21:47 2014 +0200
@@ -305,7 +305,7 @@
# required by the tests (or some brave tester)
if self.ui.configbool('experimental', 'bundle2-exp', False):
caps = set(caps)
- capsblob = bundle2.encodecaps(bundle2.capabilities)
+ capsblob = bundle2.encodecaps(bundle2.getrepocaps(self))
caps.add('bundle2-exp=' + urllib.quote(capsblob))
return caps
--- a/mercurial/wireproto.py Mon Aug 25 19:17:06 2014 +0200
+++ b/mercurial/wireproto.py Mon Aug 25 19:21:47 2014 +0200
@@ -609,7 +609,7 @@
else:
caps.append('streamreqs=%s' % ','.join(requiredformats))
if repo.ui.configbool('experimental', 'bundle2-exp', False):
- capsblob = bundle2.encodecaps(bundle2.capabilities)
+ capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo))
caps.append('bundle2-exp=' + urllib.quote(capsblob))
caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
caps.append('httpheader=1024')