Patchwork [07,of,22] obsstore: move _version to a propertycache

login
register
mail settings
Submitter Jun Wu
Date June 4, 2017, 11:59 p.m.
Message ID <8ac6041f2d9cddf3fdb7.1496620759@x1c>
Download mbox | patch
Permalink /patch/21185/
State Accepted
Headers show

Comments

Jun Wu - June 4, 2017, 11:59 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1496591355 25200
#      Sun Jun 04 08:49:15 2017 -0700
# Node ID 8ac6041f2d9cddf3fdb743bc0ae5a02584d890ec
# Parent  17ce57b7873f61deefe4ee34c4b7b9e6a54d489e
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 8ac6041f2d9c
obsstore: move _version to a propertycache

This makes sure _version is correct even if "_all" is not called.

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -556,5 +556,5 @@  class obsstore(object):
         self.caches = {}
         self.svfs = svfs
-        self._version = defaultformat
+        self._defaultformat = defaultformat
         self._readonly = readonly
 
@@ -671,4 +671,11 @@  class obsstore(object):
 
     @propertycache
+    def _version(self):
+        if len(self._data) >= 1:
+            return _readmarkerversion(self._data)
+        else:
+            return self._defaultformat
+
+    @propertycache
     def _all(self):
         data = self._data