changeset 26541:d40029b4296e

bundle2: split parameter retrieval and processing We want to introduce a simple way to forward the content of a bundle2 stream. For this purpose, we will need to both yield the parameters block and process it (to apply any behavior change it might indicate).
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 05 Oct 2015 01:10:49 -0700
parents 7469067de2ba
children b87e4638dabf
files mercurial/bundle2.py
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Mon Oct 05 00:14:47 2015 -0700
+++ b/mercurial/bundle2.py	Mon Oct 05 01:10:49 2015 -0700
@@ -657,15 +657,23 @@
             raise error.BundleValueError('negative bundle param size: %i'
                                          % paramssize)
         if paramssize:
-            for p in self._readexact(paramssize).split(' '):
-                p = p.split('=', 1)
-                p = [urllib.unquote(i) for i in p]
-                if len(p) < 2:
-                    p.append(None)
-                self._processparam(*p)
-                params[p[0]] = p[1]
+            params = self._readexact(paramssize)
+            params = self._processallparams(params)
         return params
 
+    def _processallparams(self, paramsblock):
+        """"""
+        params = {}
+        for p in paramsblock.split(' '):
+            p = p.split('=', 1)
+            p = [urllib.unquote(i) for i in p]
+            if len(p) < 2:
+                p.append(None)
+            self._processparam(*p)
+            params[p[0]] = p[1]
+        return params
+
+
     def _processparam(self, name, value):
         """process a parameter, applying its effect if needed