##// END OF EJS Templates
exchange: support parameters in bundle specification strings...
Gregory Szorc -
r26759:c0f475ac default
parent child Browse files
Show More
@@ -1244,7 +1244,7 def bundle(ui, repo, fname, dest=None, *
1244 1244
1245 1245 bundletype = opts.get('type', 'bzip2').lower()
1246 1246 try:
1247 bcompression, cgversion = exchange.parsebundlespec(
1247 bcompression, cgversion, params = exchange.parsebundlespec(
1248 1248 repo, bundletype, strict=False)
1249 1249 except error.UnsupportedBundleSpecification as e:
1250 1250 raise error.Abort(str(e),
@@ -39,10 +39,12 def parsebundlespec(repo, spec, strict=T
39 39
40 40 The string currently has the form:
41 41
42 <compression>-<type>
42 <compression>-<type>[;<parameter0>[;<parameter1>]]
43 43
44 44 Where <compression> is one of the supported compression formats
45 and <type> is (currently) a version string.
45 and <type> is (currently) a version string. A ";" can follow the type and
46 all text afterwards is interpretted as URI encoded, ";" delimited key=value
47 pairs.
46 48
47 49 If ``strict`` is True (the default) <compression> is required. Otherwise,
48 50 it is optional.
@@ -50,8 +52,8 def parsebundlespec(repo, spec, strict=T
50 52 If ``externalnames`` is False (the default), the human-centric names will
51 53 be converted to their internal representation.
52 54
53 Returns a 2-tuple of (compression, version). Compression will be ``None``
54 if not in strict mode and a compression isn't defined.
55 Returns a 3-tuple of (compression, version, parameters). Compression will
56 be ``None`` if not in strict mode and a compression isn't defined.
55 57
56 58 An ``InvalidBundleSpecification`` is raised when the specification is
57 59 not syntactically well formed.
@@ -62,6 +64,27 def parsebundlespec(repo, spec, strict=T
62 64 Note: this function will likely eventually return a more complex data
63 65 structure, including bundle2 part information.
64 66 """
67 def parseparams(s):
68 if ';' not in s:
69 return s, {}
70
71 params = {}
72 version, paramstr = s.split(';', 1)
73
74 for p in paramstr.split(';'):
75 if '=' not in p:
76 raise error.InvalidBundleSpecification(
77 _('invalid bundle specification: '
78 'missing "=" in parameter: %s') % p)
79
80 key, value = p.split('=', 1)
81 key = urllib.unquote(key)
82 value = urllib.unquote(value)
83 params[key] = value
84
85 return version, params
86
87
65 88 if strict and '-' not in spec:
66 89 raise error.InvalidBundleSpecification(
67 90 _('invalid bundle specification; '
@@ -74,6 +97,8 def parsebundlespec(repo, spec, strict=T
74 97 raise error.UnsupportedBundleSpecification(
75 98 _('%s compression is not supported') % compression)
76 99
100 version, params = parseparams(version)
101
77 102 if version not in _bundlespeccgversions:
78 103 raise error.UnsupportedBundleSpecification(
79 104 _('%s is not a recognized bundle version') % version)
@@ -82,6 +107,8 def parsebundlespec(repo, spec, strict=T
82 107 # case some defaults are assumed (but only when not in strict mode).
83 108 assert not strict
84 109
110 spec, params = parseparams(spec)
111
85 112 if spec in _bundlespeccompressions:
86 113 compression = spec
87 114 version = 'v1'
@@ -100,7 +127,7 def parsebundlespec(repo, spec, strict=T
100 127 if not externalnames:
101 128 compression = _bundlespeccompressions[compression]
102 129 version = _bundlespeccgversions[version]
103 return compression, version
130 return compression, version, params
104 131
105 132 def readbundle(ui, fh, fname, vfs=None):
106 133 header = changegroup.readexactly(fh, 4)
@@ -1691,8 +1718,8 def parseclonebundlesmanifest(repo, s):
1691 1718 # component of the BUNDLESPEC.
1692 1719 if key == 'BUNDLESPEC':
1693 1720 try:
1694 comp, version = parsebundlespec(repo, value,
1695 externalnames=True)
1721 comp, version, params = parsebundlespec(repo, value,
1722 externalnames=True)
1696 1723 attrs['COMPRESSION'] = comp
1697 1724 attrs['VERSION'] = version
1698 1725 except error.InvalidBundleSpecification:
General Comments 0
You need to be logged in to leave comments. Login now