##// END OF EJS Templates
bundlerepo: make bundle and bundlefile attributes private...
Gregory Szorc -
r35043:df2a676a default
parent child Browse files
Show More
@@ -281,11 +281,11 b' class bundlerepository(localrepo.localre'
281
281
282 self.tempfile = None
282 self.tempfile = None
283 f = util.posixfile(bundlepath, "rb")
283 f = util.posixfile(bundlepath, "rb")
284 self.bundlefile = self.bundle = exchange.readbundle(ui, f, bundlepath)
284 self._bundlefile = self._bundle = exchange.readbundle(ui, f, bundlepath)
285
285
286 if isinstance(self.bundle, bundle2.unbundle20):
286 if isinstance(self._bundle, bundle2.unbundle20):
287 hadchangegroup = False
287 hadchangegroup = False
288 for part in self.bundle.iterparts():
288 for part in self._bundle.iterparts():
289 if part.type == 'changegroup':
289 if part.type == 'changegroup':
290 if hadchangegroup:
290 if hadchangegroup:
291 raise NotImplementedError("can't process "
291 raise NotImplementedError("can't process "
@@ -296,16 +296,15 b' class bundlerepository(localrepo.localre'
296
296
297 if not hadchangegroup:
297 if not hadchangegroup:
298 raise error.Abort(_("No changegroups found"))
298 raise error.Abort(_("No changegroups found"))
299 elif isinstance(self.bundle, changegroup.cg1unpacker):
299 elif isinstance(self._bundle, changegroup.cg1unpacker):
300 if self.bundle.compressed():
300 if self._bundle.compressed():
301 f = self._writetempbundle(self.bundle.read, '.hg10un',
301 f = self._writetempbundle(self._bundle.read, '.hg10un',
302 header='HG10UN')
302 header='HG10UN')
303 self.bundlefile = self.bundle = exchange.readbundle(ui, f,
303 self._bundlefile = self._bundle = exchange.readbundle(
304 bundlepath,
304 ui, f, bundlepath, self.vfs)
305 self.vfs)
306 else:
305 else:
307 raise error.Abort(_('bundle type %s cannot be read') %
306 raise error.Abort(_('bundle type %s cannot be read') %
308 type(self.bundle))
307 type(self._bundle))
309
308
310 # dict with the mapping 'filename' -> position in the bundle
309 # dict with the mapping 'filename' -> position in the bundle
311 self.bundlefilespos = {}
310 self.bundlefilespos = {}
@@ -322,11 +321,11 b' class bundlerepository(localrepo.localre'
322 if version not in legalcgvers:
321 if version not in legalcgvers:
323 msg = _('Unsupported changegroup version: %s')
322 msg = _('Unsupported changegroup version: %s')
324 raise error.Abort(msg % version)
323 raise error.Abort(msg % version)
325 if self.bundle.compressed():
324 if self._bundle.compressed():
326 cgstream = self._writetempbundle(part.read,
325 cgstream = self._writetempbundle(part.read,
327 ".cg%sun" % version)
326 ".cg%sun" % version)
328
327
329 self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
328 self._bundle = changegroup.getunbundler(version, cgstream, 'UN')
330
329
331 def _writetempbundle(self, readfn, suffix, header=''):
330 def _writetempbundle(self, readfn, suffix, header=''):
332 """Write a temporary file to disk
331 """Write a temporary file to disk
@@ -352,28 +351,28 b' class bundlerepository(localrepo.localre'
352 @localrepo.unfilteredpropertycache
351 @localrepo.unfilteredpropertycache
353 def changelog(self):
352 def changelog(self):
354 # consume the header if it exists
353 # consume the header if it exists
355 self.bundle.changelogheader()
354 self._bundle.changelogheader()
356 c = bundlechangelog(self.svfs, self.bundle)
355 c = bundlechangelog(self.svfs, self._bundle)
357 self.manstart = self.bundle.tell()
356 self.manstart = self._bundle.tell()
358 return c
357 return c
359
358
360 def _constructmanifest(self):
359 def _constructmanifest(self):
361 self.bundle.seek(self.manstart)
360 self._bundle.seek(self.manstart)
362 # consume the header if it exists
361 # consume the header if it exists
363 self.bundle.manifestheader()
362 self._bundle.manifestheader()
364 linkmapper = self.unfiltered().changelog.rev
363 linkmapper = self.unfiltered().changelog.rev
365 m = bundlemanifest(self.svfs, self.bundle, linkmapper)
364 m = bundlemanifest(self.svfs, self._bundle, linkmapper)
366 self.filestart = self.bundle.tell()
365 self.filestart = self._bundle.tell()
367 return m
366 return m
368
367
369 def _consumemanifest(self):
368 def _consumemanifest(self):
370 """Consumes the manifest portion of the bundle, setting filestart so the
369 """Consumes the manifest portion of the bundle, setting filestart so the
371 file portion can be read."""
370 file portion can be read."""
372 self.bundle.seek(self.manstart)
371 self._bundle.seek(self.manstart)
373 self.bundle.manifestheader()
372 self._bundle.manifestheader()
374 for delta in self.bundle.deltaiter():
373 for delta in self._bundle.deltaiter():
375 pass
374 pass
376 self.filestart = self.bundle.tell()
375 self.filestart = self._bundle.tell()
377
376
378 @localrepo.unfilteredpropertycache
377 @localrepo.unfilteredpropertycache
379 def manstart(self):
378 def manstart(self):
@@ -398,19 +397,19 b' class bundlerepository(localrepo.localre'
398
397
399 def file(self, f):
398 def file(self, f):
400 if not self.bundlefilespos:
399 if not self.bundlefilespos:
401 self.bundle.seek(self.filestart)
400 self._bundle.seek(self.filestart)
402 self.bundlefilespos = _getfilestarts(self.bundle)
401 self.bundlefilespos = _getfilestarts(self._bundle)
403
402
404 if f in self.bundlefilespos:
403 if f in self.bundlefilespos:
405 self.bundle.seek(self.bundlefilespos[f])
404 self._bundle.seek(self.bundlefilespos[f])
406 linkmapper = self.unfiltered().changelog.rev
405 linkmapper = self.unfiltered().changelog.rev
407 return bundlefilelog(self.svfs, f, self.bundle, linkmapper)
406 return bundlefilelog(self.svfs, f, self._bundle, linkmapper)
408 else:
407 else:
409 return filelog.filelog(self.svfs, f)
408 return filelog.filelog(self.svfs, f)
410
409
411 def close(self):
410 def close(self):
412 """Close assigned bundle file immediately."""
411 """Close assigned bundle file immediately."""
413 self.bundlefile.close()
412 self._bundlefile.close()
414 if self.tempfile is not None:
413 if self.tempfile is not None:
415 self.vfs.unlink(self.tempfile)
414 self.vfs.unlink(self.tempfile)
416 if self._tempparent:
415 if self._tempparent:
General Comments 0
You need to be logged in to leave comments. Login now