##// END OF EJS Templates
dirstate: lazify initdirs
Matt Mackall -
r4605:9da7a4da default
parent child Browse files
Show More
@@ -20,7 +20,6 b' class dirstate(object):'
20 20 self.root = root
21 21 self.dirty = 0
22 22 self.ui = ui
23 self.dirs = None
24 23 self.ignorefunc = None
25 24 self._slash = None
26 25
@@ -47,6 +46,11 b' class dirstate(object):'
47 46 except IOError, err:
48 47 if err.errno != errno.ENOENT: raise
49 48 return self.pl
49 elif name == 'dirs':
50 self.dirs = {}
51 for f in self.map:
52 self.updatedirs(f, 1)
53 return self.dirs
50 54 else:
51 55 raise AttributeError, name
52 56
@@ -256,24 +260,16 b' class dirstate(object):'
256 260 def copies(self):
257 261 return self.copymap
258 262
259 def initdirs(self):
260 if self.dirs is None:
261 self.dirs = {}
262 for f in self.map:
263 self.updatedirs(f, 1)
264
265 263 def updatedirs(self, path, delta):
266 if self.dirs is not None:
267 for c in strutil.findall(path, '/'):
268 pc = path[:c]
269 self.dirs.setdefault(pc, 0)
270 self.dirs[pc] += delta
264 for c in strutil.findall(path, '/'):
265 pc = path[:c]
266 self.dirs.setdefault(pc, 0)
267 self.dirs[pc] += delta
271 268
272 269 def checkinterfering(self, files):
273 270 def prefixes(f):
274 271 for c in strutil.rfindall(f, '/'):
275 272 yield f[:c]
276 self.initdirs()
277 273 seendirs = {}
278 274 for f in files:
279 275 # shadows
@@ -301,7 +297,6 b' class dirstate(object):'
301 297 if not files: return
302 298 self.markdirty()
303 299 if state == "a":
304 self.initdirs()
305 300 self.checkinterfering(files)
306 301 for f in files:
307 302 if state == "r":
@@ -320,7 +315,6 b' class dirstate(object):'
320 315 def forget(self, files):
321 316 if not files: return
322 317 self.markdirty()
323 self.initdirs()
324 318 for f in files:
325 319 try:
326 320 del self.map[f]
General Comments 0
You need to be logged in to leave comments. Login now