##// END OF EJS Templates
dirstate: use getattr rather than lazyread
Matt Mackall -
r4603:0f6853c1 default
parent child Browse files
Show More
@@ -20,7 +20,6 b' class dirstate(object):'
20 self.root = root
20 self.root = root
21 self.dirty = 0
21 self.dirty = 0
22 self.ui = ui
22 self.ui = ui
23 self.map = None
24 self.fp = None
23 self.fp = None
25 self.pl = None
24 self.pl = None
26 self.dirs = None
25 self.dirs = None
@@ -29,6 +28,13 b' class dirstate(object):'
29 self._branch = None
28 self._branch = None
30 self._slash = None
29 self._slash = None
31
30
31 def __getattr__(self, name):
32 if name == 'map':
33 self.read()
34 return self.map
35 else:
36 raise AttributeError, name
37
32 def wjoin(self, f):
38 def wjoin(self, f):
33 return os.path.join(self.root, f)
39 return os.path.join(self.root, f)
34
40
@@ -142,11 +148,7 b' class dirstate(object):'
142 self.write()
148 self.write()
143
149
144 def __getitem__(self, key):
150 def __getitem__(self, key):
145 try:
151 return self.map[key]
146 return self.map[key]
147 except TypeError:
148 self.lazyread()
149 return self[key]
150
152
151 _unknown = ('?', 0, 0, 0)
153 _unknown = ('?', 0, 0, 0)
152
154
@@ -157,7 +159,6 b' class dirstate(object):'
157 return self._unknown
159 return self._unknown
158
160
159 def __contains__(self, key):
161 def __contains__(self, key):
160 self.lazyread()
161 return key in self.map
162 return key in self.map
162
163
163 def parents(self):
164 def parents(self):
@@ -186,7 +187,6 b' class dirstate(object):'
186 self.dirty = 1
187 self.dirty = 1
187
188
188 def setparents(self, p1, p2=nullid):
189 def setparents(self, p1, p2=nullid):
189 self.lazyread()
190 self.markdirty()
190 self.markdirty()
191 self.pl = p1, p2
191 self.pl = p1, p2
192
192
@@ -200,10 +200,6 b' class dirstate(object):'
200 except KeyError:
200 except KeyError:
201 return "?"
201 return "?"
202
202
203 def lazyread(self):
204 if self.map is None:
205 self.read()
206
207 def parse(self, st):
203 def parse(self, st):
208 self.pl = [st[:20], st[20: 40]]
204 self.pl = [st[:20], st[20: 40]]
209
205
@@ -255,7 +251,6 b' class dirstate(object):'
255 self.ignorefunc = None
251 self.ignorefunc = None
256
252
257 def copy(self, source, dest):
253 def copy(self, source, dest):
258 self.lazyread()
259 self.markdirty()
254 self.markdirty()
260 self.copymap[dest] = source
255 self.copymap[dest] = source
261
256
@@ -282,7 +277,6 b' class dirstate(object):'
282 def prefixes(f):
277 def prefixes(f):
283 for c in strutil.rfindall(f, '/'):
278 for c in strutil.rfindall(f, '/'):
284 yield f[:c]
279 yield f[:c]
285 self.lazyread()
286 self.initdirs()
280 self.initdirs()
287 seendirs = {}
281 seendirs = {}
288 for f in files:
282 for f in files:
@@ -309,7 +303,6 b' class dirstate(object):'
309 a marked for addition'''
303 a marked for addition'''
310
304
311 if not files: return
305 if not files: return
312 self.lazyread()
313 self.markdirty()
306 self.markdirty()
314 if state == "a":
307 if state == "a":
315 self.initdirs()
308 self.initdirs()
@@ -330,7 +323,6 b' class dirstate(object):'
330
323
331 def forget(self, files):
324 def forget(self, files):
332 if not files: return
325 if not files: return
333 self.lazyread()
334 self.markdirty()
326 self.markdirty()
335 self.initdirs()
327 self.initdirs()
336 for f in files:
328 for f in files:
@@ -438,7 +430,6 b' class dirstate(object):'
438
430
439 and st is the stat result if the file was found in the directory.
431 and st is the stat result if the file was found in the directory.
440 '''
432 '''
441 self.lazyread()
442
433
443 # walk all files by default
434 # walk all files by default
444 if not files:
435 if not files:
General Comments 0
You need to be logged in to leave comments. Login now