These attributes are implementation details and shouldn't be
exposed outside the class.
.. api::
bundlerepo.bundlerepository.bundle and bundlerepo.bundlerepository.bundlefile are now prefixed with an underscore.
| dlax | |
| durin42 |
| hg-reviewers |
These attributes are implementation details and shouldn't be
exposed outside the class.
.. api::
bundlerepo.bundlerepository.bundle and bundlerepo.bundlerepository.bundlefile are now prefixed with an underscore.
| Automatic diff as part of commit; lint not applicable. |
| Automatic diff as part of commit; unit tests not applicable. |
| if repopath: | if repopath: | ||||
| self._url = 'bundle:' + util.expandpath(repopath) + '+' + bundlepath | self._url = 'bundle:' + util.expandpath(repopath) + '+' + bundlepath | ||||
| else: | else: | ||||
| self._url = 'bundle:' + bundlepath | self._url = 'bundle:' + bundlepath | ||||
| self.tempfile = None | self.tempfile = None | ||||
| f = util.posixfile(bundlepath, "rb") | f = util.posixfile(bundlepath, "rb") | ||||
| self.bundlefile = self.bundle = exchange.readbundle(ui, f, bundlepath) | self._bundlefile = self._bundle = exchange.readbundle(ui, f, bundlepath) | ||||
| if isinstance(self.bundle, bundle2.unbundle20): | if isinstance(self._bundle, bundle2.unbundle20): | ||||
| hadchangegroup = False | hadchangegroup = False | ||||
| for part in self.bundle.iterparts(): | for part in self._bundle.iterparts(): | ||||
| if part.type == 'changegroup': | if part.type == 'changegroup': | ||||
| if hadchangegroup: | if hadchangegroup: | ||||
| raise NotImplementedError("can't process " | raise NotImplementedError("can't process " | ||||
| "multiple changegroups") | "multiple changegroups") | ||||
| hadchangegroup = True | hadchangegroup = True | ||||
| self._handlebundle2part(part) | self._handlebundle2part(part) | ||||
| if not hadchangegroup: | if not hadchangegroup: | ||||
| raise error.Abort(_("No changegroups found")) | raise error.Abort(_("No changegroups found")) | ||||
| elif isinstance(self.bundle, changegroup.cg1unpacker): | elif isinstance(self._bundle, changegroup.cg1unpacker): | ||||
| if self.bundle.compressed(): | if self._bundle.compressed(): | ||||
| f = self._writetempbundle(self.bundle.read, '.hg10un', | f = self._writetempbundle(self._bundle.read, '.hg10un', | ||||
| header='HG10UN') | header='HG10UN') | ||||
| self.bundlefile = self.bundle = exchange.readbundle(ui, f, | self._bundlefile = self._bundle = exchange.readbundle( | ||||
| bundlepath, | ui, f, bundlepath, self.vfs) | ||||
| self.vfs) | |||||
| else: | else: | ||||
| raise error.Abort(_('bundle type %s cannot be read') % | raise error.Abort(_('bundle type %s cannot be read') % | ||||
| type(self.bundle)) | type(self._bundle)) | ||||
| # dict with the mapping 'filename' -> position in the bundle | # dict with the mapping 'filename' -> position in the bundle | ||||
| self.bundlefilespos = {} | self.bundlefilespos = {} | ||||
| self.firstnewrev = self.changelog.repotiprev + 1 | self.firstnewrev = self.changelog.repotiprev + 1 | ||||
| phases.retractboundary(self, None, phases.draft, | phases.retractboundary(self, None, phases.draft, | ||||
| [ctx.node() for ctx in self[self.firstnewrev:]]) | [ctx.node() for ctx in self[self.firstnewrev:]]) | ||||
| def _handlebundle2part(self, part): | def _handlebundle2part(self, part): | ||||
| if part.type == 'changegroup': | if part.type == 'changegroup': | ||||
| cgstream = part | cgstream = part | ||||
| version = part.params.get('version', '01') | version = part.params.get('version', '01') | ||||
| legalcgvers = changegroup.supportedincomingversions(self) | legalcgvers = changegroup.supportedincomingversions(self) | ||||
| if version not in legalcgvers: | if version not in legalcgvers: | ||||
| msg = _('Unsupported changegroup version: %s') | msg = _('Unsupported changegroup version: %s') | ||||
| raise error.Abort(msg % version) | raise error.Abort(msg % version) | ||||
| if self.bundle.compressed(): | if self._bundle.compressed(): | ||||
| cgstream = self._writetempbundle(part.read, | cgstream = self._writetempbundle(part.read, | ||||
| ".cg%sun" % version) | ".cg%sun" % version) | ||||
| self.bundle = changegroup.getunbundler(version, cgstream, 'UN') | self._bundle = changegroup.getunbundler(version, cgstream, 'UN') | ||||
| def _writetempbundle(self, readfn, suffix, header=''): | def _writetempbundle(self, readfn, suffix, header=''): | ||||
| """Write a temporary file to disk | """Write a temporary file to disk | ||||
| """ | """ | ||||
| fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-", | fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-", | ||||
| suffix=suffix) | suffix=suffix) | ||||
| self.tempfile = temp | self.tempfile = temp | ||||
| @localrepo.unfilteredpropertycache | @localrepo.unfilteredpropertycache | ||||
| def _phasecache(self): | def _phasecache(self): | ||||
| return bundlephasecache(self, self._phasedefaults) | return bundlephasecache(self, self._phasedefaults) | ||||
| @localrepo.unfilteredpropertycache | @localrepo.unfilteredpropertycache | ||||
| def changelog(self): | def changelog(self): | ||||
| # consume the header if it exists | # consume the header if it exists | ||||
| self.bundle.changelogheader() | self._bundle.changelogheader() | ||||
| c = bundlechangelog(self.svfs, self.bundle) | c = bundlechangelog(self.svfs, self._bundle) | ||||
| self.manstart = self.bundle.tell() | self.manstart = self._bundle.tell() | ||||
| return c | return c | ||||
| def _constructmanifest(self): | def _constructmanifest(self): | ||||
| self.bundle.seek(self.manstart) | self._bundle.seek(self.manstart) | ||||
| # consume the header if it exists | # consume the header if it exists | ||||
| self.bundle.manifestheader() | self._bundle.manifestheader() | ||||
| linkmapper = self.unfiltered().changelog.rev | linkmapper = self.unfiltered().changelog.rev | ||||
| m = bundlemanifest(self.svfs, self.bundle, linkmapper) | m = bundlemanifest(self.svfs, self._bundle, linkmapper) | ||||
| self.filestart = self.bundle.tell() | self.filestart = self._bundle.tell() | ||||
| return m | return m | ||||
| def _consumemanifest(self): | def _consumemanifest(self): | ||||
| """Consumes the manifest portion of the bundle, setting filestart so the | """Consumes the manifest portion of the bundle, setting filestart so the | ||||
| file portion can be read.""" | file portion can be read.""" | ||||
| self.bundle.seek(self.manstart) | self._bundle.seek(self.manstart) | ||||
| self.bundle.manifestheader() | self._bundle.manifestheader() | ||||
| for delta in self.bundle.deltaiter(): | for delta in self._bundle.deltaiter(): | ||||
| pass | pass | ||||
| self.filestart = self.bundle.tell() | self.filestart = self._bundle.tell() | ||||
| @localrepo.unfilteredpropertycache | @localrepo.unfilteredpropertycache | ||||
| def manstart(self): | def manstart(self): | ||||
| self.changelog | self.changelog | ||||
| return self.manstart | return self.manstart | ||||
| @localrepo.unfilteredpropertycache | @localrepo.unfilteredpropertycache | ||||
| def filestart(self): | def filestart(self): | ||||
| self.manifestlog | self.manifestlog | ||||
| # If filestart was not set by self.manifestlog, that means the | # If filestart was not set by self.manifestlog, that means the | ||||
| # manifestlog implementation did not consume the manifests from the | # manifestlog implementation did not consume the manifests from the | ||||
| # changegroup (ex: it might be consuming trees from a separate bundle2 | # changegroup (ex: it might be consuming trees from a separate bundle2 | ||||
| # part instead). So we need to manually consume it. | # part instead). So we need to manually consume it. | ||||
| if 'filestart' not in self.__dict__: | if 'filestart' not in self.__dict__: | ||||
| self._consumemanifest() | self._consumemanifest() | ||||
| return self.filestart | return self.filestart | ||||
| def url(self): | def url(self): | ||||
| return self._url | return self._url | ||||
| def file(self, f): | def file(self, f): | ||||
| if not self.bundlefilespos: | if not self.bundlefilespos: | ||||
| self.bundle.seek(self.filestart) | self._bundle.seek(self.filestart) | ||||
| self.bundlefilespos = _getfilestarts(self.bundle) | self.bundlefilespos = _getfilestarts(self._bundle) | ||||
| if f in self.bundlefilespos: | if f in self.bundlefilespos: | ||||
| self.bundle.seek(self.bundlefilespos[f]) | self._bundle.seek(self.bundlefilespos[f]) | ||||
| linkmapper = self.unfiltered().changelog.rev | linkmapper = self.unfiltered().changelog.rev | ||||
| return bundlefilelog(self.svfs, f, self.bundle, linkmapper) | return bundlefilelog(self.svfs, f, self._bundle, linkmapper) | ||||
| else: | else: | ||||
| return filelog.filelog(self.svfs, f) | return filelog.filelog(self.svfs, f) | ||||
| def close(self): | def close(self): | ||||
| """Close assigned bundle file immediately.""" | """Close assigned bundle file immediately.""" | ||||
| self.bundlefile.close() | self._bundlefile.close() | ||||
| if self.tempfile is not None: | if self.tempfile is not None: | ||||
| self.vfs.unlink(self.tempfile) | self.vfs.unlink(self.tempfile) | ||||
| if self._tempparent: | if self._tempparent: | ||||
| shutil.rmtree(self._tempparent, True) | shutil.rmtree(self._tempparent, True) | ||||
| def cancopy(self): | def cancopy(self): | ||||
| return False | return False | ||||