comparison mercurial/obsolete.py @ 26309:44918682093f

obsstore: delay loading markers from obsstore file This will allow us to use cached revisions without parsing obsstore. Because _version isn't determined at __init__, the debugobsconvert command no longer works correctly. I'll fix it by a separate patch for the evolve extension.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 13 Sep 2015 17:52:37 +0900
parents f2788794183a
children 61efe9ef6ad4
comparison
equal deleted inserted replaced
26308:f2788794183a 26309:44918682093f
518 # None is used when no data has been recorded 518 # None is used when no data has been recorded
519 519
520 def __init__(self, svfs, defaultformat=_fm1version, readonly=False): 520 def __init__(self, svfs, defaultformat=_fm1version, readonly=False):
521 # caches for various obsolescence related cache 521 # caches for various obsolescence related cache
522 self.caches = {} 522 self.caches = {}
523 self._all = []
524 self.svfs = svfs 523 self.svfs = svfs
525 data = svfs.tryread('obsstore')
526 self._version = defaultformat 524 self._version = defaultformat
527 self._readonly = readonly 525 self._readonly = readonly
528 if data:
529 self._version, markers = _readmarkers(data)
530 markers = list(markers)
531 _checkinvalidmarkers(markers)
532 self._all = markers
533 526
534 def __iter__(self): 527 def __iter__(self):
535 return iter(self._all) 528 return iter(self._all)
536 529
537 def __len__(self): 530 def __len__(self):
613 """merge a binary stream of markers inside the obsstore 606 """merge a binary stream of markers inside the obsstore
614 607
615 Returns the number of new markers added.""" 608 Returns the number of new markers added."""
616 version, markers = _readmarkers(data) 609 version, markers = _readmarkers(data)
617 return self.add(transaction, markers) 610 return self.add(transaction, markers)
611
612 @propertycache
613 def _all(self):
614 data = self.svfs.tryread('obsstore')
615 if not data:
616 return []
617 self._version, markers = _readmarkers(data)
618 markers = list(markers)
619 _checkinvalidmarkers(markers)
620 return markers
618 621
619 @propertycache 622 @propertycache
620 def successors(self): 623 def successors(self):
621 successors = {} 624 successors = {}
622 _addsuccessors(successors, self._all) 625 _addsuccessors(successors, self._all)