changeset 21143:5bb5d4ba14e5

bundle2: transmit capabilities to getbundle during pull Bundle2 capabilities of the client are sent to the server in the bundlecaps argument of `getbundle`.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 17 Apr 2014 02:01:38 -0400
parents 15039ce3e4a3
children 7a20fe8dc080
files mercurial/exchange.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Thu Apr 17 14:37:24 2014 -0400
+++ b/mercurial/exchange.py	Thu Apr 17 02:01:38 2014 -0400
@@ -546,6 +546,8 @@
 
     For now, the only supported data are changegroup."""
     kwargs = {'bundlecaps': set(['HG20'])}
+    capsblob = bundle2.encodecaps(pullop.repo.bundle2caps)
+    kwargs['bundlecaps'].add('bundle2=' + urllib.quote(capsblob))
     # pulling changegroup
     pullop.todosteps.remove('changegroup')
     if not pullop.fetch:
@@ -660,7 +662,12 @@
         return cg
     # very crude first implementation,
     # the bundle API will change and the generation will be done lazily.
-    bundler = bundle2.bundle20(repo.ui)
+    b2caps = {}
+    for bcaps in bundlecaps:
+        if bcaps.startswith('bundle2='):
+            blob = urllib.unquote(bcaps[len('bundle2='):])
+            b2caps.update(bundle2.decodecaps(blob))
+    bundler = bundle2.bundle20(repo.ui, b2caps)
     part = bundle2.bundlepart('changegroup', data=cg.getchunks())
     bundler.addpart(part)
     return util.chunkbuffer(bundler.getchunks())