bundlespec: drop externalnames flag
authorJoerg Sonnenberger <joerg@bec.de>
Tue, 17 Apr 2018 02:41:25 +0200
changeset 37768 5527aa808dea
parent 37767 44d1959acb3b
child 37769 6a7ff5816c5f
bundlespec: drop externalnames flag Always provide the human readable version of compression and version. Add the translated wire format name in the new wirecompression and wireversion fields. Differential Revision: https://phab.mercurial-scm.org/D3392
mercurial/commands.py
mercurial/exchange.py
--- a/mercurial/commands.py	Mon Apr 16 23:29:09 2018 -0700
+++ b/mercurial/commands.py	Tue Apr 17 02:41:25 2018 +0200
@@ -1245,14 +1245,12 @@
         scmutil.nochangesfound(ui, repo, not base and outgoing.excluded)
         return 1
 
-    bcompression = bundlespec.compression
     if cgversion == '01': #bundle1
-        if bcompression is None:
-            bcompression = 'UN'
-        bversion = 'HG10' + bcompression
+        bversion = 'HG10' + bundlespec.wirecompression
         bcompression = None
     elif cgversion in ('02', '03'):
         bversion = 'HG20'
+        bcompression = bundlespec.wirecompression
     else:
         raise error.ProgrammingError(
             'bundle: unexpected changegroup version %s' % cgversion)
--- a/mercurial/exchange.py	Mon Apr 16 23:29:09 2018 -0700
+++ b/mercurial/exchange.py	Tue Apr 17 02:41:25 2018 +0200
@@ -86,11 +86,13 @@
 @attr.s
 class bundlespec(object):
     compression = attr.ib()
+    wirecompression = attr.ib()
     version = attr.ib()
+    wireversion = attr.ib()
     params = attr.ib()
     contentopts = attr.ib()
 
-def parsebundlespec(repo, spec, strict=True, externalnames=False):
+def parsebundlespec(repo, spec, strict=True):
     """Parse a bundle string specification into parts.
 
     Bundle specifications denote a well-defined bundle/exchange format.
@@ -110,9 +112,6 @@
     If ``strict`` is True (the default) <compression> is required. Otherwise,
     it is optional.
 
-    If ``externalnames`` is False (the default), the human-centric names will
-    be converted to their internal representation.
-
     Returns a bundlespec object of (compression, version, parameters).
     Compression will be ``None`` if not in strict mode and a compression isn't
     defined.
@@ -215,12 +214,12 @@
         variant = _bundlespecvariants["streamv2"]
         contentopts.update(variant)
 
-    if not externalnames:
-        engine = util.compengines.forbundlename(compression)
-        compression = engine.bundletype()[1]
-        version = _bundlespeccgversions[version]
+    engine = util.compengines.forbundlename(compression)
+    compression, wirecompression = engine.bundletype()
+    wireversion = _bundlespeccgversions[version]
 
-    return bundlespec(compression, version, params, contentopts)
+    return bundlespec(compression, wirecompression, version, wireversion,
+                      params, contentopts)
 
 def readbundle(ui, fh, fname, vfs=None):
     header = changegroup.readexactly(fh, 4)
@@ -2253,8 +2252,7 @@
             # component of the BUNDLESPEC.
             if key == 'BUNDLESPEC':
                 try:
-                    bundlespec = parsebundlespec(repo, value,
-                                                 externalnames=True)
+                    bundlespec = parsebundlespec(repo, value)
                     attrs['COMPRESSION'] = bundlespec.compression
                     attrs['VERSION'] = bundlespec.version
                 except error.InvalidBundleSpecification:
@@ -2268,11 +2266,12 @@
 
 def isstreamclonespec(bundlespec):
     # Stream clone v1
-    if (bundlespec.compression == 'UN' and bundlespec.version == 's1'):
+    if (bundlespec.wirecompression == 'UN' and bundlespec.wireversion == 's1'):
         return True
 
     # Stream clone v2
-    if (bundlespec.compression == 'UN' and bundlespec.version == '02' and \
+    if (bundlespec.wirecompression == 'UN' and \
+        bundlespec.wireversion == '02' and \
         bundlespec.contentopts.get('streamv2')):
         return True