Mercurial > public > mercurial-scm > hg
comparison mercurial/bundlerepo.py @ 35054:3f393e4593f2
bundlerepo: rename _bundle to _cgunpacker
_bundle is really a changegroup unpacker instance. Rename the
variable accordingly.
Differential Revision: https://phab.mercurial-scm.org/D1379
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 11 Nov 2017 18:41:14 -0800 |
parents | 495fcff10124 |
children | 3eeb0a3eeaed |
comparison
equal
deleted
inserted
replaced
35053:495fcff10124 | 35054:3f393e4593f2 |
---|---|
283 f = util.posixfile(bundlepath, "rb") | 283 f = util.posixfile(bundlepath, "rb") |
284 bundle = exchange.readbundle(ui, f, bundlepath) | 284 bundle = exchange.readbundle(ui, f, bundlepath) |
285 | 285 |
286 if isinstance(bundle, bundle2.unbundle20): | 286 if isinstance(bundle, bundle2.unbundle20): |
287 self._bundlefile = bundle | 287 self._bundlefile = bundle |
288 self._bundle = None | 288 self._cgunpacker = None |
289 | 289 |
290 hadchangegroup = False | 290 hadchangegroup = False |
291 for part in bundle.iterparts(): | 291 for part in bundle.iterparts(): |
292 if part.type == 'changegroup': | 292 if part.type == 'changegroup': |
293 if hadchangegroup: | 293 if hadchangegroup: |
304 f = self._writetempbundle(bundle.read, '.hg10un', | 304 f = self._writetempbundle(bundle.read, '.hg10un', |
305 header='HG10UN') | 305 header='HG10UN') |
306 bundle = exchange.readbundle(ui, f, bundlepath, self.vfs) | 306 bundle = exchange.readbundle(ui, f, bundlepath, self.vfs) |
307 | 307 |
308 self._bundlefile = bundle | 308 self._bundlefile = bundle |
309 self._bundle = bundle | 309 self._cgunpacker = bundle |
310 else: | 310 else: |
311 raise error.Abort(_('bundle type %s cannot be read') % | 311 raise error.Abort(_('bundle type %s cannot be read') % |
312 type(bundle)) | 312 type(bundle)) |
313 | 313 |
314 # dict with the mapping 'filename' -> position in the bundle | 314 # dict with the mapping 'filename' -> position in the bundle |
328 raise error.Abort(msg % version) | 328 raise error.Abort(msg % version) |
329 if bundle.compressed(): | 329 if bundle.compressed(): |
330 cgstream = self._writetempbundle(part.read, | 330 cgstream = self._writetempbundle(part.read, |
331 ".cg%sun" % version) | 331 ".cg%sun" % version) |
332 | 332 |
333 self._bundle = changegroup.getunbundler(version, cgstream, 'UN') | 333 self._cgunpacker = changegroup.getunbundler(version, cgstream, |
334 'UN') | |
334 | 335 |
335 def _writetempbundle(self, readfn, suffix, header=''): | 336 def _writetempbundle(self, readfn, suffix, header=''): |
336 """Write a temporary file to disk | 337 """Write a temporary file to disk |
337 """ | 338 """ |
338 fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-", | 339 fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-", |
354 return bundlephasecache(self, self._phasedefaults) | 355 return bundlephasecache(self, self._phasedefaults) |
355 | 356 |
356 @localrepo.unfilteredpropertycache | 357 @localrepo.unfilteredpropertycache |
357 def changelog(self): | 358 def changelog(self): |
358 # consume the header if it exists | 359 # consume the header if it exists |
359 self._bundle.changelogheader() | 360 self._cgunpacker.changelogheader() |
360 c = bundlechangelog(self.svfs, self._bundle) | 361 c = bundlechangelog(self.svfs, self._cgunpacker) |
361 self.manstart = self._bundle.tell() | 362 self.manstart = self._cgunpacker.tell() |
362 return c | 363 return c |
363 | 364 |
364 def _constructmanifest(self): | 365 def _constructmanifest(self): |
365 self._bundle.seek(self.manstart) | 366 self._cgunpacker.seek(self.manstart) |
366 # consume the header if it exists | 367 # consume the header if it exists |
367 self._bundle.manifestheader() | 368 self._cgunpacker.manifestheader() |
368 linkmapper = self.unfiltered().changelog.rev | 369 linkmapper = self.unfiltered().changelog.rev |
369 m = bundlemanifest(self.svfs, self._bundle, linkmapper) | 370 m = bundlemanifest(self.svfs, self._cgunpacker, linkmapper) |
370 self.filestart = self._bundle.tell() | 371 self.filestart = self._cgunpacker.tell() |
371 return m | 372 return m |
372 | 373 |
373 def _consumemanifest(self): | 374 def _consumemanifest(self): |
374 """Consumes the manifest portion of the bundle, setting filestart so the | 375 """Consumes the manifest portion of the bundle, setting filestart so the |
375 file portion can be read.""" | 376 file portion can be read.""" |
376 self._bundle.seek(self.manstart) | 377 self._cgunpacker.seek(self.manstart) |
377 self._bundle.manifestheader() | 378 self._cgunpacker.manifestheader() |
378 for delta in self._bundle.deltaiter(): | 379 for delta in self._cgunpacker.deltaiter(): |
379 pass | 380 pass |
380 self.filestart = self._bundle.tell() | 381 self.filestart = self._cgunpacker.tell() |
381 | 382 |
382 @localrepo.unfilteredpropertycache | 383 @localrepo.unfilteredpropertycache |
383 def manstart(self): | 384 def manstart(self): |
384 self.changelog | 385 self.changelog |
385 return self.manstart | 386 return self.manstart |
400 def url(self): | 401 def url(self): |
401 return self._url | 402 return self._url |
402 | 403 |
403 def file(self, f): | 404 def file(self, f): |
404 if not self.bundlefilespos: | 405 if not self.bundlefilespos: |
405 self._bundle.seek(self.filestart) | 406 self._cgunpacker.seek(self.filestart) |
406 self.bundlefilespos = _getfilestarts(self._bundle) | 407 self.bundlefilespos = _getfilestarts(self._cgunpacker) |
407 | 408 |
408 if f in self.bundlefilespos: | 409 if f in self.bundlefilespos: |
409 self._bundle.seek(self.bundlefilespos[f]) | 410 self._cgunpacker.seek(self.bundlefilespos[f]) |
410 linkmapper = self.unfiltered().changelog.rev | 411 linkmapper = self.unfiltered().changelog.rev |
411 return bundlefilelog(self.svfs, f, self._bundle, linkmapper) | 412 return bundlefilelog(self.svfs, f, self._cgunpacker, linkmapper) |
412 else: | 413 else: |
413 return filelog.filelog(self.svfs, f) | 414 return filelog.filelog(self.svfs, f) |
414 | 415 |
415 def close(self): | 416 def close(self): |
416 """Close assigned bundle file immediately.""" | 417 """Close assigned bundle file immediately.""" |