obsstore: delay loading markers from obsstore file
authorYuya Nishihara <yuya@tcha.org>
Sun, 13 Sep 2015 17:52:37 +0900
changeset 26309 44918682093f
parent 26308 f2788794183a
child 26310 61efe9ef6ad4
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.
mercurial/obsolete.py
--- a/mercurial/obsolete.py	Sun Sep 13 17:47:18 2015 +0900
+++ b/mercurial/obsolete.py	Sun Sep 13 17:52:37 2015 +0900
@@ -520,16 +520,9 @@
     def __init__(self, svfs, defaultformat=_fm1version, readonly=False):
         # caches for various obsolescence related cache
         self.caches = {}
-        self._all = []
         self.svfs = svfs
-        data = svfs.tryread('obsstore')
         self._version = defaultformat
         self._readonly = readonly
-        if data:
-            self._version, markers = _readmarkers(data)
-            markers = list(markers)
-            _checkinvalidmarkers(markers)
-            self._all = markers
 
     def __iter__(self):
         return iter(self._all)
@@ -617,6 +610,16 @@
         return self.add(transaction, markers)
 
     @propertycache
+    def _all(self):
+        data = self.svfs.tryread('obsstore')
+        if not data:
+            return []
+        self._version, markers = _readmarkers(data)
+        markers = list(markers)
+        _checkinvalidmarkers(markers)
+        return markers
+
+    @propertycache
     def successors(self):
         successors = {}
         _addsuccessors(successors, self._all)