##// END OF EJS Templates
bundlespec: fix the generation of bundlespec for `cg.version`...
marmoute -
r50229:6d15a897 default
parent child Browse files
Show More
@@ -80,6 +80,14 b' def readbundle(ui, fh, fname, vfs=None):'
80 80 )
81 81
82 82
83 def _format_params(params):
84 parts = []
85 for key, value in sorted(params.items()):
86 value = urlreq.quote(value)
87 parts.append(b"%s=%s" % (key, value))
88 return b';'.join(parts)
89
90
83 91 def getbundlespec(ui, fh):
84 92 """Infer the bundlespec from a bundle file handle.
85 93
@@ -93,6 +101,8 b' def getbundlespec(ui, fh):'
93 101 except KeyError:
94 102 return None
95 103
104 params = {}
105
96 106 b = readbundle(ui, fh, None)
97 107 if isinstance(b, changegroup.cg1unpacker):
98 108 alg = b._type
@@ -115,9 +125,12 b' def getbundlespec(ui, fh):'
115 125 version = None
116 126 for part in b.iterparts():
117 127 if part.type == b'changegroup':
118 version = part.params[b'version']
119 if version in (b'01', b'02'):
128 cgversion = part.params[b'version']
129 if cgversion in (b'01', b'02'):
120 130 version = b'v2'
131 elif cgversion in (b'03',):
132 version = b'v2'
133 params[b'cg.version'] = cgversion
121 134 else:
122 135 raise error.Abort(
123 136 _(
@@ -138,8 +151,12 b' def getbundlespec(ui, fh):'
138 151 raise error.Abort(
139 152 _(b'could not identify changegroup version in bundle')
140 153 )
141
142 return b'%s-%s' % (comp, version)
154 spec = b'%s-%s' % (comp, version)
155 if params:
156 spec += b';'
157 spec += _format_params(params)
158 return spec
159
143 160 elif isinstance(b, streamclone.streamcloneapplier):
144 161 requirements = streamclone.readbundle1header(fh)[2]
145 162 formatted = bundle2._formatrequirementsparams(requirements)
@@ -265,6 +265,4 b' Test controlling the changegroup version'
265 265 changegroup -- {nbchanges: 1, version: 03} (mandatory: True)
266 266 c35a0f9217e65d1fdb90c936ffa7dbe679f83ddf
267 267 $ hg debugbundle ./v2-cg-03.hg --spec
268 abort: changegroup version 03 does not have a known bundlespec (known-bad-output !)
269 (try upgrading your Mercurial client) (known-bad-output !)
270 [255]
268 bzip2-v2;cg.version=03
General Comments 0
You need to be logged in to leave comments. Login now