obsstore: move _version to a propertycache
authorJun Wu <quark@fb.com>
Sun, 04 Jun 2017 08:49:15 -0700
changeset 32691 5d8dd6c90af9
parent 32690 3fad59faba8a
child 32692 9576974a3b6d
obsstore: move _version to a propertycache This makes sure _version is correct even if "_all" is not called.
mercurial/obsolete.py
--- a/mercurial/obsolete.py	Fri Jun 02 20:38:01 2017 -0700
+++ b/mercurial/obsolete.py	Sun Jun 04 08:49:15 2017 -0700
@@ -555,7 +555,7 @@
         # caches for various obsolescence related cache
         self.caches = {}
         self.svfs = svfs
-        self._version = defaultformat
+        self._defaultformat = defaultformat
         self._readonly = readonly
 
     def __iter__(self):
@@ -670,6 +670,13 @@
         return self.svfs.tryread('obsstore')
 
     @propertycache
+    def _version(self):
+        if len(self._data) >= 1:
+            return _readmarkerversion(self._data)
+        else:
+            return self._defaultformat
+
+    @propertycache
     def _all(self):
         data = self._data
         if not data: