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