##// END OF EJS Templates
localrepo: use propertycache
Matt Mackall -
r8260:54a4b520 default
parent child Browse files
Show More
@@ -209,25 +209,28 b' class bundlerepository(localrepo.localre'
209 209 # dict with the mapping 'filename' -> position in the bundle
210 210 self.bundlefilespos = {}
211 211
212 def __getattr__(self, name):
213 if name == 'changelog':
214 self.changelog = bundlechangelog(self.sopener, self.bundlefile)
215 self.manstart = self.bundlefile.tell()
216 return self.changelog
217 elif name == 'manifest':
218 self.bundlefile.seek(self.manstart)
219 self.manifest = bundlemanifest(self.sopener, self.bundlefile,
220 self.changelog.rev)
221 self.filestart = self.bundlefile.tell()
222 return self.manifest
223 elif name == 'manstart':
224 self.changelog
225 return self.manstart
226 elif name == 'filestart':
227 self.manifest
228 return self.filestart
229 else:
230 return localrepo.localrepository.__getattr__(self, name)
212 @util.propertycache
213 def changelog(self):
214 c = bundlechangelog(self.sopener, self.bundlefile)
215 self.manstart = self.bundlefile.tell()
216 return c
217
218 @util.propertycache
219 def manifest(self):
220 self.bundlefile.seek(self.manstart)
221 m = bundlemanifest(self.sopener, self.bundlefile, self.changelog.rev)
222 self.filestart = self.bundlefile.tell()
223 return m
224
225 @util.propertycache
226 def manstart(self):
227 self.changelog
228 return self.manstart
229
230 @util.propertycache
231 def filestart(self):
232 self.manifest
233 return self.filestart
231 234
232 235 def url(self):
233 236 return self._url
@@ -15,6 +15,7 b' import match as match_'
15 15 import merge as merge_
16 16
17 17 from lock import release
18 propertycache = util.propertycache
18 19
19 20 class localrepository(repo.repository):
20 21 capabilities = set(('lookup', 'changegroupsubset'))
@@ -88,24 +89,23 b' class localrepository(repo.repository):'
88 89 self._datafilters = {}
89 90 self._transref = self._lockref = self._wlockref = None
90 91
91 def __getattr__(self, name):
92 if name == 'changelog':
93 self.changelog = changelog.changelog(self.sopener)
94 if 'HG_PENDING' in os.environ:
95 p = os.environ['HG_PENDING']
96 if p.startswith(self.root):
97 self.changelog.readpending('00changelog.i.a')
98 self.sopener.defversion = self.changelog.version
99 return self.changelog
100 if name == 'manifest':
101 self.changelog
102 self.manifest = manifest.manifest(self.sopener)
103 return self.manifest
104 if name == 'dirstate':
105 self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root)
106 return self.dirstate
107 else:
108 raise AttributeError(name)
92 @propertycache
93 def changelog(self):
94 c = changelog.changelog(self.sopener)
95 if 'HG_PENDING' in os.environ:
96 p = os.environ['HG_PENDING']
97 if p.startswith(self.root):
98 c.readpending('00changelog.i.a')
99 self.sopener.defversion = c.version
100 return c
101
102 @propertycache
103 def manifest(self):
104 return manifest.manifest(self.sopener)
105
106 @propertycache
107 def dirstate(self):
108 return dirstate.dirstate(self.opener, self.ui, self.root)
109 109
110 110 def __getitem__(self, changeid):
111 111 if changeid == None:
General Comments 0
You need to be logged in to leave comments. Login now