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