Mercurial > hg
changeset 26803:ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Before this bundle repository were unable to work with compressed
bundle2. We use the same approach as with bundle1, we extract the
changegroup in uncompressed form into a temporary file.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 19 Oct 2015 16:01:55 +0200 |
parents | 42f705f2c02d |
children | 612502900a2d |
files | mercurial/bundlerepo.py |
diffstat | 1 files changed, 17 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundlerepo.py Fri Oct 02 23:21:39 2015 -0700 +++ b/mercurial/bundlerepo.py Mon Oct 19 16:01:55 2015 +0200 @@ -277,22 +277,26 @@ self.bundlefile = self.bundle = exchange.readbundle(ui, f, bundlename) if isinstance(self.bundle, bundle2.unbundle20): - cgparts = [part for part in self.bundle.iterparts() - if (part.type == 'changegroup') - and (part.params.get('version', '01') - in changegroup.packermap)] + cgstream = None + for part in self.bundle.iterparts(): + if part.type == 'changegroup': + if cgstream is not None: + raise NotImplementedError("can't process " + "multiple changegroups") + cgstream = part + version = part.params.get('version', '01') + if version not in changegroup.packermap: + msg = _('Unsupported changegroup version: %s') + raise error.Abort(msg % version) + if self.bundle.compressed(): + cgstream = _writetempbundle(part.read, + ".cg%sun" % version) - if not cgparts: + if cgstream is None: raise error.Abort('No changegroups found') - version = cgparts[0].params.get('version', '01') - cgparts = [p for p in cgparts - if p.params.get('version', '01') == version] - if len(cgparts) > 1: - raise NotImplementedError("Can't process multiple changegroups") - part = cgparts[0] + cgstream.seek(0) - part.seek(0) - self.bundle = changegroup.packermap[version][1](part, 'UN') + self.bundle = changegroup.packermap[version][1](cgstream, 'UN') elif self.bundle.compressed(): f = _writetempbundle(self.bundle.read, '.hg10un', header='HG10UN')