Skip to content
Snippets Groups Projects
Commit df2a676a authored by Gregory Szorc's avatar Gregory Szorc
Browse files

bundlerepo: make bundle and bundlefile attributes private

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.

Differential Revision: https://phab.mercurial-scm.org/D1377
parent 4f04c920
No related branches found
No related tags found
No related merge requests found
......@@ -281,5 +281,5 @@
self.tempfile = None
f = util.posixfile(bundlepath, "rb")
self.bundlefile = self.bundle = exchange.readbundle(ui, f, bundlepath)
self._bundlefile = self._bundle = exchange.readbundle(ui, f, bundlepath)
......@@ -285,3 +285,3 @@
if isinstance(self.bundle, bundle2.unbundle20):
if isinstance(self._bundle, bundle2.unbundle20):
hadchangegroup = False
......@@ -287,5 +287,5 @@
hadchangegroup = False
for part in self.bundle.iterparts():
for part in self._bundle.iterparts():
if part.type == 'changegroup':
if hadchangegroup:
raise NotImplementedError("can't process "
......@@ -296,7 +296,7 @@
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(self._bundle, changegroup.cg1unpacker):
if self._bundle.compressed():
f = self._writetempbundle(self._bundle.read, '.hg10un',
header='HG10UN')
......@@ -302,6 +302,5 @@
header='HG10UN')
self.bundlefile = self.bundle = exchange.readbundle(ui, f,
bundlepath,
self.vfs)
self._bundlefile = self._bundle = exchange.readbundle(
ui, f, bundlepath, self.vfs)
else:
raise error.Abort(_('bundle type %s cannot be read') %
......@@ -306,6 +305,6 @@
else:
raise error.Abort(_('bundle type %s cannot be read') %
type(self.bundle))
type(self._bundle))
# dict with the mapping 'filename' -> position in the bundle
self.bundlefilespos = {}
......@@ -322,7 +321,7 @@
if version not in legalcgvers:
msg = _('Unsupported changegroup version: %s')
raise error.Abort(msg % version)
if self.bundle.compressed():
if self._bundle.compressed():
cgstream = self._writetempbundle(part.read,
".cg%sun" % version)
......@@ -326,7 +325,7 @@
cgstream = self._writetempbundle(part.read,
".cg%sun" % version)
self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
self._bundle = changegroup.getunbundler(version, cgstream, 'UN')
def _writetempbundle(self, readfn, suffix, header=''):
"""Write a temporary file to disk
......@@ -352,9 +351,9 @@
@localrepo.unfilteredpropertycache
def changelog(self):
# consume the header if it exists
self.bundle.changelogheader()
c = bundlechangelog(self.svfs, self.bundle)
self.manstart = self.bundle.tell()
self._bundle.changelogheader()
c = bundlechangelog(self.svfs, self._bundle)
self.manstart = self._bundle.tell()
return c
def _constructmanifest(self):
......@@ -358,5 +357,5 @@
return c
def _constructmanifest(self):
self.bundle.seek(self.manstart)
self._bundle.seek(self.manstart)
# consume the header if it exists
......@@ -362,3 +361,3 @@
# consume the header if it exists
self.bundle.manifestheader()
self._bundle.manifestheader()
linkmapper = self.unfiltered().changelog.rev
......@@ -364,8 +363,8 @@
linkmapper = self.unfiltered().changelog.rev
m = bundlemanifest(self.svfs, self.bundle, linkmapper)
self.filestart = self.bundle.tell()
m = bundlemanifest(self.svfs, self._bundle, linkmapper)
self.filestart = self._bundle.tell()
return m
def _consumemanifest(self):
"""Consumes the manifest portion of the bundle, setting filestart so the
file portion can be read."""
......@@ -367,9 +366,9 @@
return m
def _consumemanifest(self):
"""Consumes the manifest portion of the bundle, setting filestart so the
file portion can be read."""
self.bundle.seek(self.manstart)
self.bundle.manifestheader()
for delta in self.bundle.deltaiter():
self._bundle.seek(self.manstart)
self._bundle.manifestheader()
for delta in self._bundle.deltaiter():
pass
......@@ -375,5 +374,5 @@
pass
self.filestart = self.bundle.tell()
self.filestart = self._bundle.tell()
@localrepo.unfilteredpropertycache
def manstart(self):
......@@ -398,7 +397,7 @@
def file(self, f):
if not self.bundlefilespos:
self.bundle.seek(self.filestart)
self.bundlefilespos = _getfilestarts(self.bundle)
self._bundle.seek(self.filestart)
self.bundlefilespos = _getfilestarts(self._bundle)
if f in self.bundlefilespos:
......@@ -403,4 +402,4 @@
if f in self.bundlefilespos:
self.bundle.seek(self.bundlefilespos[f])
self._bundle.seek(self.bundlefilespos[f])
linkmapper = self.unfiltered().changelog.rev
......@@ -406,7 +405,7 @@
linkmapper = self.unfiltered().changelog.rev
return bundlefilelog(self.svfs, f, self.bundle, linkmapper)
return bundlefilelog(self.svfs, f, self._bundle, linkmapper)
else:
return filelog.filelog(self.svfs, f)
def close(self):
"""Close assigned bundle file immediately."""
......@@ -408,9 +407,9 @@
else:
return filelog.filelog(self.svfs, f)
def close(self):
"""Close assigned bundle file immediately."""
self.bundlefile.close()
self._bundlefile.close()
if self.tempfile is not None:
self.vfs.unlink(self.tempfile)
if self._tempparent:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment