comparison mercurial/bundlerepo.py @ 35077:cd4cd7b94ff1

bundlerepo: rename "bundlefilespos" variable and attribute Strictly speaking, this variable tracks offsets within the changegroup, not the bundle. While we're here, mark a class attribute as private because it is. .. api:: Rename bundlerepo.bundlerepository.bundlefilespos to _cgfilespos. Differential Revision: https://phab.mercurial-scm.org/D1384
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 13 Nov 2017 19:12:56 -0800
parents 90609be10891
children 2b72bc88043f
comparison
equal deleted inserted replaced
35076:90609be10891 35077:cd4cd7b94ff1
245 def _updateroots(self, phase, newroots, tr): 245 def _updateroots(self, phase, newroots, tr):
246 self.phaseroots[phase] = newroots 246 self.phaseroots[phase] = newroots
247 self.invalidate() 247 self.invalidate()
248 self.dirty = True 248 self.dirty = True
249 249
250 bundlefilespos = {}
251 def _getfilestarts(cgunpacker): 250 def _getfilestarts(cgunpacker):
251 filespos = {}
252 for chunkdata in iter(cgunpacker.filelogheader, {}): 252 for chunkdata in iter(cgunpacker.filelogheader, {}):
253 fname = chunkdata['filename'] 253 fname = chunkdata['filename']
254 bundlefilespos[fname] = bundle.tell() 254 filespos[fname] = cgunpacker.tell()
255 for chunk in iter(lambda: cgunpacker.deltachunk(None), {}): 255 for chunk in iter(lambda: cgunpacker.deltachunk(None), {}):
256 pass 256 pass
257 return bundlefilespos 257 return filespos
258 258
259 class bundlerepository(localrepo.localrepository): 259 class bundlerepository(localrepo.localrepository):
260 """A repository instance that is a union of a local repo and a bundle. 260 """A repository instance that is a union of a local repo and a bundle.
261 261
262 Instances represent a read-only repository composed of a local repository 262 Instances represent a read-only repository composed of a local repository
310 self._cgunpacker = bundle 310 self._cgunpacker = bundle
311 else: 311 else:
312 raise error.Abort(_('bundle type %s cannot be read') % 312 raise error.Abort(_('bundle type %s cannot be read') %
313 type(bundle)) 313 type(bundle))
314 314
315 # dict with the mapping 'filename' -> position in the bundle 315 # dict with the mapping 'filename' -> position in the changegroup.
316 self.bundlefilespos = {} 316 self._cgfilespos = {}
317 317
318 self.firstnewrev = self.changelog.repotiprev + 1 318 self.firstnewrev = self.changelog.repotiprev + 1
319 phases.retractboundary(self, None, phases.draft, 319 phases.retractboundary(self, None, phases.draft,
320 [ctx.node() for ctx in self[self.firstnewrev:]]) 320 [ctx.node() for ctx in self[self.firstnewrev:]])
321 321
401 401
402 def url(self): 402 def url(self):
403 return self._url 403 return self._url
404 404
405 def file(self, f): 405 def file(self, f):
406 if not self.bundlefilespos: 406 if not self._cgfilespos:
407 self._cgunpacker.seek(self.filestart) 407 self._cgunpacker.seek(self.filestart)
408 self.bundlefilespos = _getfilestarts(self._cgunpacker) 408 self._cgfilespos = _getfilestarts(self._cgunpacker)
409 409
410 if f in self.bundlefilespos: 410 if f in self._cgfilespos:
411 self._cgunpacker.seek(self.bundlefilespos[f]) 411 self._cgunpacker.seek(self._cgfilespos[f])
412 linkmapper = self.unfiltered().changelog.rev 412 linkmapper = self.unfiltered().changelog.rev
413 return bundlefilelog(self.svfs, f, self._cgunpacker, linkmapper) 413 return bundlefilelog(self.svfs, f, self._cgunpacker, linkmapper)
414 else: 414 else:
415 return filelog.filelog(self.svfs, f) 415 return filelog.filelog(self.svfs, f)
416 416