bundle2: support for unbundling simple parameter
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 18 Mar 2014 15:56:24 -0700
changeset 20805 c5aaeca0cfbf
parent 20804 db9d3991d2c6
child 20806 d66862b87ae6
bundle2: support for unbundling simple parameter the unbundler now understand simple list of parameter.
mercurial/bundle2.py
tests/test-bundle2.t
--- a/mercurial/bundle2.py	Wed Mar 19 14:52:03 2014 -0700
+++ b/mercurial/bundle2.py	Tue Mar 18 15:56:24 2014 -0700
@@ -142,9 +142,12 @@
     @util.propertycache
     def params(self):
         """dictionnary of stream level parameters"""
-        paramsize = self._readexact(2)
-        assert paramsize == '\0\0'
-        return {}
+        params = {}
+        paramssize = self._unpack(_fstreamparamsize)[0]
+        if paramssize:
+            for p in self._readexact(paramssize).split(' '):
+                params[p] = None
+        return params
 
     def __iter__(self):
         """yield all parts contained in the stream"""
--- a/tests/test-bundle2.t	Wed Mar 19 14:52:03 2014 -0700
+++ b/tests/test-bundle2.t	Tue Mar 18 15:56:24 2014 -0700
@@ -30,6 +30,8 @@
   >     """read a bundle2 container from standard input"""
   >     unbundler = bundle2.unbundle20(sys.stdin)
   >     ui.write('options count: %i\n' % len(unbundler.params))
+  >     for key in sorted(unbundler.params):
+  >         ui.write('- %s\n' % key)
   >     parts = list(unbundler)
   >     ui.write('parts count:   %i\n' % len(parts))
   > EOF
@@ -83,12 +85,28 @@
 
 Simplest possible parameters form
 
-Test generation
+Test generation simple option
 
   $ hg bundle2 --param 'caution'
   HG20\x00\x07caution\x00\x00 (no-eol) (esc)
 
+Test unbundling
+
+  $ hg bundle2 --param 'caution' | hg unbundle2
+  options count: 1
+  - caution
+  parts count:   0
+
 Test generation multiple option
 
   $ hg bundle2 --param 'caution' --param 'meal'
   HG20\x00\x0ccaution meal\x00\x00 (no-eol) (esc)
+
+Test unbundling
+
+  $ hg bundle2 --param 'caution' --param 'meal' | hg unbundle2
+  options count: 2
+  - caution
+  - meal
+  parts count:   0
+