changeset 35812:84965e5f3241 stable

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
author Boris Feld <boris.feld@octobus.net>
date Mon, 29 Jan 2018 10:28:10 +0100
parents e35320ce8043
children 768326377e4d
files mercurial/exchange.py
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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)