Patchwork [3,of,7] bundle2: support for unbundling parameter value

login
register
mail settings
Submitter Pierre-Yves David
Date March 21, 2014, 9:57 p.m.
Message ID <eb7c292fe0ad0d7b03d1.1395439048@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4026/
State Accepted
Commit 47293877b54c13a46dca4ffd8086d572a86af6e7
Headers show

Comments

Pierre-Yves David - March 21, 2014, 9:57 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1395184353 25200
#      Tue Mar 18 16:12:33 2014 -0700
# Node ID eb7c292fe0ad0d7b03d1776955f3c51762b90bb4
# Parent  fabb16544076272f78e918f7ba026f31b955fee2
bundle2: support for unbundling parameter value

The unbundler now understand parameter value. introduced in the previous
changeset.

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -150,11 +150,14 @@  class unbundle20(object):
         """dictionnary of stream level parameters"""
         params = {}
         paramssize = self._unpack(_fstreamparamsize)[0]
         if paramssize:
             for p in self._readexact(paramssize).split(' '):
-                params[p] = None
+                p = p.split('=', 1)
+                if len(p) < 2:
+                    p.append(None)
+                params[p[0]] = p[1]
         return params
 
     def __iter__(self):
         """yield all parts contained in the stream"""
         # make sure param have been loaded
diff --git a/tests/test-bundle2.t b/tests/test-bundle2.t
--- a/tests/test-bundle2.t
+++ b/tests/test-bundle2.t
@@ -32,10 +32,13 @@  Create an extension to test bundle2 API
   >     """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)
+  >         value = unbundler.params[key]
+  >         if value is not None:
+  >             ui.write('    %s\n' % value)
   >     parts = list(unbundler)
   >     ui.write('parts count:   %i\n' % len(parts))
   > EOF
   $ cat >> $HGRCPATH << EOF
   > [extensions]
@@ -118,5 +121,14 @@  advisory parameters, with value
 Test generation
 
   $ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants'
   HG20\x00\x1ccaution meal=vegan elephants\x00\x00 (no-eol) (esc)
 
+Test unbundling
+
+  $ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants' | hg unbundle2
+  options count: 3
+  - caution
+  - elephants
+  - meal
+      vegan
+  parts count:   0