exchange: support preserving external names when parsing bundle specs
authorGregory Szorc <gregory.szorc@gmail.com>
Tue, 13 Oct 2015 12:29:50 -0700
changeset 26646 77769354d4ad
parent 26645 2faa7671a4b3
child 26647 62b0fa0d8787
exchange: support preserving external names when parsing bundle specs This will be needed to make client-side preferences work easier.
mercurial/exchange.py
--- a/mercurial/exchange.py	Tue Oct 13 10:59:41 2015 -0700
+++ b/mercurial/exchange.py	Tue Oct 13 12:29:50 2015 -0700
@@ -28,7 +28,7 @@
                          'bundle2': '02', #legacy
                         }
 
-def parsebundlespec(repo, spec, strict=True):
+def parsebundlespec(repo, spec, strict=True, externalnames=False):
     """Parse a bundle string specification into parts.
 
     Bundle specifications denote a well-defined bundle/exchange format.
@@ -46,6 +46,9 @@
     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 2-tuple of (compression, version). Compression will be ``None``
     if not in strict mode and a compression isn't defined.
 
@@ -90,8 +93,9 @@
             raise error.UnsupportedBundleSpecification(
                     _('%s is not a recognized bundle specification') % spec)
 
-    compression = _bundlespeccompressions[compression]
-    version = _bundlespeccgversions[version]
+    if not externalnames:
+        compression = _bundlespeccompressions[compression]
+        version = _bundlespeccgversions[version]
     return compression, version
 
 def readbundle(ui, fh, fname, vfs=None):