[PATCH 5 of 6 RFC] localrepo: add changelog, manifestlog, and dirstate to immutable type

Gregory Szorc gregory.szorc at gmail.com
Fri Jun 9 02:36:09 EDT 2017


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1496981366 25200
#      Thu Jun 08 21:09:26 2017 -0700
# Node ID 1075b79fc1809c69e1819c654ea1f635c70f1d70
# Parent  0b779b2671892a99bce634078b84eae13aa6a189
localrepo: add changelog, manifestlog, and dirstate to immutable type

These can be plain properties on the immutable type because since the
repo is immutable, they should never change.

We can't have the old class call into the base class because they
may obtain a cached and therefore stale copy! So we have to
duplicate some small methods. Oh well. But we can move the
_constructmanifest() support method to the base type.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -481,6 +481,26 @@ class immutablelocalrepository(object):
             pass
         return filteredrepo(self, name)
 
+    @util.propertycache
+    def changelog(self):
+        return changelog.changelog(self.svfs,
+                                   trypending=txnutil.mayhavepending(self.root))
+
+    def _constructmanifest(self):
+        # This is a temporary function while we migrate from manifest to
+        # manifestlog. It allows bundlerepo and unionrepo to intercept the
+        # manifest creation.
+        return manifest.manifestrevlog(self.svfs)
+
+    @util.propertycache
+    def manifestlog(self):
+        return manifest.manifestlog(self.svfs, self)
+
+    @util.propertycache
+    def dirstate(self):
+        return dirstate.dirstate(self.vfs, self.ui, self.root,
+                                 self._dirstatevalidate)
+
 class localrepository(immutablelocalrepository):
 
     def __init__(self, baseui, path, create=False):
@@ -552,12 +572,6 @@ class localrepository(immutablelocalrepo
         return changelog.changelog(self.svfs,
                                    trypending=txnutil.mayhavepending(self.root))
 
-    def _constructmanifest(self):
-        # This is a temporary function while we migrate from manifest to
-        # manifestlog. It allows bundlerepo and unionrepo to intercept the
-        # manifest creation.
-        return manifest.manifestrevlog(self.svfs)
-
     @storecache('00manifest.i')
     def manifestlog(self):
         return manifest.manifestlog(self.svfs, self)


More information about the Mercurial-devel mailing list