Patchwork [2,of,5,RFC] obsstore: delay loading markers from obsstore file

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 23, 2015, 5:48 a.m.
Message ID <3e6c365f6630059e4c1e.1442987283@mimosa>
Download mbox | patch
Permalink /patch/10589/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 23, 2015, 5:48 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1442134357 -32400
#      Sun Sep 13 17:52:37 2015 +0900
# Node ID 3e6c365f6630059e4c1ee4fbf7ce2aa557e1821f
# Parent  85f2c8734f280440aea2f51b530c5af6964b9215
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.

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -520,16 +520,9 @@  class obsstore(object):
     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 @@  class obsstore(object):
         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)