# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 2015-10-05 08:10:49
# Node ID d40029b4296e986f210ad9bc8bee1ce1523fd189
# Parent  7469067de2ba69273c5327f6fa47eaa7a1857d2e

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).

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -657,15 +657,23 @@ class unbundle20(unpackermixin):
             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