From patchwork Mon Nov 13 23:16:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D1378: bundlerepo: assign bundle attributes in bundle type blocks From: phabricator X-Patchwork-Id: 25537 Message-Id: <726fcd4995564d05b601e44f6fd9502a@localhost.localdomain> To: mercurial-devel@mercurial-scm.org Date: Mon, 13 Nov 2017 23:16:33 +0000 This revision was automatically updated to reflect the committed changes. Closed by commit rHG495fcff10124: bundlerepo: assign bundle attributes in bundle type blocks (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D1378?vs=3433&id=3456 REVISION DETAIL https://phab.mercurial-scm.org/D1378 AFFECTED FILES mercurial/bundlerepo.py CHANGE DETAILS To: indygreg, #hg-reviewers, dlax, durin42 Cc: mercurial-devel diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py +++ b/mercurial/bundlerepo.py @@ -281,47 +281,52 @@ self.tempfile = None f = util.posixfile(bundlepath, "rb") - self._bundlefile = self._bundle = exchange.readbundle(ui, f, bundlepath) + bundle = exchange.readbundle(ui, f, bundlepath) - if isinstance(self._bundle, bundle2.unbundle20): + if isinstance(bundle, bundle2.unbundle20): + self._bundlefile = bundle + self._bundle = None + hadchangegroup = False - for part in self._bundle.iterparts(): + for part in bundle.iterparts(): if part.type == 'changegroup': if hadchangegroup: raise NotImplementedError("can't process " "multiple changegroups") hadchangegroup = True - self._handlebundle2part(part) + self._handlebundle2part(bundle, part) if not hadchangegroup: raise error.Abort(_("No changegroups found")) - elif isinstance(self._bundle, changegroup.cg1unpacker): - if self._bundle.compressed(): - f = self._writetempbundle(self._bundle.read, '.hg10un', + elif isinstance(bundle, changegroup.cg1unpacker): + if bundle.compressed(): + f = self._writetempbundle(bundle.read, '.hg10un', header='HG10UN') - self._bundlefile = self._bundle = exchange.readbundle( - ui, f, bundlepath, self.vfs) + bundle = exchange.readbundle(ui, f, bundlepath, self.vfs) + + self._bundlefile = bundle + self._bundle = bundle else: raise error.Abort(_('bundle type %s cannot be read') % - type(self._bundle)) + type(bundle)) # dict with the mapping 'filename' -> position in the bundle self.bundlefilespos = {} self.firstnewrev = self.changelog.repotiprev + 1 phases.retractboundary(self, None, phases.draft, [ctx.node() for ctx in self[self.firstnewrev:]]) - def _handlebundle2part(self, part): + def _handlebundle2part(self, bundle, part): if part.type == 'changegroup': cgstream = part version = part.params.get('version', '01') legalcgvers = changegroup.supportedincomingversions(self) if version not in legalcgvers: msg = _('Unsupported changegroup version: %s') raise error.Abort(msg % version) - if self._bundle.compressed(): + if bundle.compressed(): cgstream = self._writetempbundle(part.read, ".cg%sun" % version)