Patchwork D1949: streamclone: extract requirements formatting

login
register
mail settings
Submitter phabricator
Date Jan. 31, 2018, 4:24 p.m.
Message ID <differential-rev-PHID-DREV-eoywyv4uowsuiw5spc6e-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27087/
State Superseded
Headers show

Comments

phabricator - Jan. 31, 2018, 4:24 p.m.
lothiraldan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It will be reused for the formatting of the requirements of the stream v2 part
  requirement and later for the stream v2 requirements.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1949

AFFECTED FILES
  mercurial/exchange.py

CHANGE DETAILS




To: lothiraldan, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -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)