localrepo: demand-load changeset, manifest, and dirstate
authorMatt Mackall <mpm@selenic.com>
Wed, 13 Jun 2007 13:15:51 -0500
changeset 4559 eda59019dc69
parent 4558 9338be783398
child 4560 3daed3680554
localrepo: demand-load changeset, manifest, and dirstate
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Tue Jun 12 10:34:54 2007 -0500
+++ b/mercurial/localrepo.py	Wed Jun 13 13:15:51 2007 -0500
@@ -79,10 +79,6 @@
         except IOError:
             pass
 
-        self.changelog = changelog.changelog(self.sopener)
-        self.sopener.defversion = self.changelog.version
-        self.manifest = manifest.manifest(self.sopener)
-
         fallback = self.ui.config('ui', 'fallbackencoding')
         if fallback:
             util._fallbackencoding = fallback
@@ -93,7 +89,20 @@
         self.filterpats = {}
         self.transhandle = None
 
-        self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root)
+    def __getattr__(self, name):
+        if name == 'changelog':
+            self.changelog = changelog.changelog(self.sopener)
+            self.sopener.defversion = self.changelog.version
+            return self.changelog
+        if name == 'manifest':
+            self.changelog
+            self.manifest = manifest.manifest(self.sopener)
+            return self.manifest
+        if name == 'dirstate':
+            self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root)
+            return self.dirstate
+        else:
+            raise AttributeError, name
 
     def url(self):
         return 'file:' + self.root