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 | def getbundlespec(ui, fh): |
|
91 | def getbundlespec(ui, fh): | |
84 | """Infer the bundlespec from a bundle file handle. |
|
92 | """Infer the bundlespec from a bundle file handle. | |
85 |
|
93 | |||
@@ -93,6 +101,8 b' def getbundlespec(ui, fh):' | |||||
93 | except KeyError: |
|
101 | except KeyError: | |
94 | return None |
|
102 | return None | |
95 |
|
103 | |||
|
104 | params = {} | |||
|
105 | ||||
96 | b = readbundle(ui, fh, None) |
|
106 | b = readbundle(ui, fh, None) | |
97 | if isinstance(b, changegroup.cg1unpacker): |
|
107 | if isinstance(b, changegroup.cg1unpacker): | |
98 | alg = b._type |
|
108 | alg = b._type | |
@@ -115,9 +125,12 b' def getbundlespec(ui, fh):' | |||||
115 | version = None |
|
125 | version = None | |
116 | for part in b.iterparts(): |
|
126 | for part in b.iterparts(): | |
117 | if part.type == b'changegroup': |
|
127 | if part.type == b'changegroup': | |
118 | version = part.params[b'version'] |
|
128 | cgversion = part.params[b'version'] | |
119 | if version in (b'01', b'02'): |
|
129 | if cgversion in (b'01', b'02'): | |
120 | version = b'v2' |
|
130 | version = b'v2' | |
|
131 | elif cgversion in (b'03',): | |||
|
132 | version = b'v2' | |||
|
133 | params[b'cg.version'] = cgversion | |||
121 | else: |
|
134 | else: | |
122 | raise error.Abort( |
|
135 | raise error.Abort( | |
123 | _( |
|
136 | _( | |
@@ -138,8 +151,12 b' def getbundlespec(ui, fh):' | |||||
138 | raise error.Abort( |
|
151 | raise error.Abort( | |
139 | _(b'could not identify changegroup version in bundle') |
|
152 | _(b'could not identify changegroup version in bundle') | |
140 | ) |
|
153 | ) | |
141 |
|
154 | spec = b'%s-%s' % (comp, version) | ||
142 | return b'%s-%s' % (comp, version) |
|
155 | if params: | |
|
156 | spec += b';' | |||
|
157 | spec += _format_params(params) | |||
|
158 | return spec | |||
|
159 | ||||
143 | elif isinstance(b, streamclone.streamcloneapplier): |
|
160 | elif isinstance(b, streamclone.streamcloneapplier): | |
144 | requirements = streamclone.readbundle1header(fh)[2] |
|
161 | requirements = streamclone.readbundle1header(fh)[2] | |
145 | formatted = bundle2._formatrequirementsparams(requirements) |
|
162 | formatted = bundle2._formatrequirementsparams(requirements) |
@@ -265,6 +265,4 b' Test controlling the changegroup version' | |||||
265 | changegroup -- {nbchanges: 1, version: 03} (mandatory: True) |
|
265 | changegroup -- {nbchanges: 1, version: 03} (mandatory: True) | |
266 | c35a0f9217e65d1fdb90c936ffa7dbe679f83ddf |
|
266 | c35a0f9217e65d1fdb90c936ffa7dbe679f83ddf | |
267 | $ hg debugbundle ./v2-cg-03.hg --spec |
|
267 | $ hg debugbundle ./v2-cg-03.hg --spec | |
268 | abort: changegroup version 03 does not have a known bundlespec (known-bad-output !) |
|
268 | bzip2-v2;cg.version=03 | |
269 | (try upgrading your Mercurial client) (known-bad-output !) |
|
|||
270 | [255] |
|
General Comments 0
You need to be logged in to leave comments.
Login now