changeset 32691:5d8dd6c90af9

obsstore: move _version to a propertycache This makes sure _version is correct even if "_all" is not called.
author Jun Wu <quark@fb.com>
date Sun, 04 Jun 2017 08:49:15 -0700
parents 3fad59faba8a
children 9576974a3b6d
files mercurial/obsolete.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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: