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