diff mercurial/cmdutil.py @ 26639:92d67e5729b9

exchange: move bundle specification parsing from cmdutil Clone bundles require a well-defined string to specify the type of bundle that is listed so clients can filter compatible file types. The `hg bundle` command and cmdutil.parsebundletype() already establish the beginnings of a bundle specification format. As part of formalizing this format specification so it can be used by clone bundles, we move the specification parsing bits verbatim to exchange.py, which is a more suitable place than cmdutil.py. A subsequent patch will refactor this code to make it more appropriate as a general API.
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 13 Oct 2015 11:43:21 -0700
parents 59b5e8844eb0
children bec1a579ebc4
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Tue Mar 24 00:28:28 2015 +0900
+++ b/mercurial/cmdutil.py	Tue Oct 13 11:43:21 2015 -0700
@@ -3366,56 +3366,3 @@
                        % self._suffix)
                 raise error.Abort(msg)
             self._abort()
-
-_bundlecompspecs = {'none': None,
-                    'bzip2': 'BZ',
-                    'gzip': 'GZ',
-                   }
-
-_bundleversionspecs = {'v1': '01',
-                       'v2': '02',
-                       'bundle2': '02', #legacy
-                      }
-
-def parsebundletype(repo, spec):
-    """return the internal bundle type to use from a user input
-
-    This is parsing user specified bundle type as accepted in:
-
-        'hg bundle --type TYPE'.
-
-    It accept format in the form [compression][-version]|[version]
-
-    Consensus about extensions of the format for various bundle2 feature
-    is to prefix any feature with "+". eg "+treemanifest" or "gzip+phases"
-    """
-    comp, version = None, None
-
-    if '-' in spec:
-        comp, version = spec.split('-', 1)
-    elif spec in _bundlecompspecs:
-        comp = spec
-    elif spec in _bundleversionspecs:
-        version = spec
-    else:
-        raise error.Abort(_('unknown bundle type specified with --type'))
-
-    if comp is None:
-        comp = 'BZ'
-    else:
-        try:
-            comp = _bundlecompspecs[comp]
-        except KeyError:
-            raise error.Abort(_('unknown bundle type specified with --type'))
-
-    if version is None:
-        version = '01'
-        if 'generaldelta' in repo.requirements:
-            version = '02'
-    else:
-        try:
-            version = _bundleversionspecs[version]
-        except KeyError:
-            raise error.Abort(_('unknown bundle type specified with --type'))
-
-    return version, comp