Patchwork D3392: bundlespec: drop externalnames flag

login
register
mail settings
Submitter phabricator
Date April 17, 2018, 1:09 a.m.
Message ID <differential-rev-PHID-DREV-jrrdjkdgwk4c3pkrswit-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/31149/
State Superseded
Headers show

Comments

phabricator - April 17, 2018, 1:09 a.m.
joerg.sonnenberger created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Always provide the human readable version of compression and version.
  Add the translated wire format name in the new wirecompression and
  wireversion fields.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/exchange.py

CHANGE DETAILS




To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-devel
phabricator - April 17, 2018, 1:57 p.m.
lothiraldan accepted this revision.
lothiraldan added a comment.


  LGTM, thanks for the much needed cleanup

REPOSITORY
  rHG Mercurial

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

To: joerg.sonnenberger, #hg-reviewers, lothiraldan
Cc: lothiraldan, mercurial-devel

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -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)
@@ -2241,8 +2240,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:
@@ -2256,11 +2254,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
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1243,14 +1243,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)