streamclone: extract requirements formatting stable
authorBoris Feld <boris.feld@octobus.net>
Mon, 29 Jan 2018 10:28:10 +0100
branchstable
changeset 35812 84965e5f3241
parent 35811 e35320ce8043
child 35813 768326377e4d
streamclone: extract requirements formatting It will be reused for the formatting of the requirements of the stream v2 part requirement and later for the stream v2 requirements. Differential Revision: https://phab.mercurial-scm.org/D1949
mercurial/exchange.py
--- a/mercurial/exchange.py	Tue Jan 30 22:27:45 2018 +0100
+++ b/mercurial/exchange.py	Mon Jan 29 10:28:10 2018 +0100
@@ -199,6 +199,14 @@
     else:
         raise error.Abort(_('%s: unknown bundle version %s') % (fname, version))
 
+def _formatrequirementsspec(requirements):
+    return urlreq.quote(','.join(sorted(requirements)))
+
+def _formatrequirementsparams(requirements):
+    requirements = _formatrequirementsspec(requirements)
+    params = "%s%s" % (urlreq.quote("requirements="), requirements)
+    return params
+
 def getbundlespec(ui, fh):
     """Infer the bundlespec from a bundle file handle.
 
@@ -247,8 +255,7 @@
         return '%s-%s' % (comp, version)
     elif isinstance(b, streamclone.streamcloneapplier):
         requirements = streamclone.readbundle1header(fh)[2]
-        params = 'requirements=%s' % ','.join(sorted(requirements))
-        return 'none-packed1;%s' % urlreq.quote(params)
+        return 'none-packed1;%s' % _formatrequirementsparams(requirements)
     else:
         raise error.Abort(_('unknown bundle type: %s') % b)