##// 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 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.dirs = None
24 self.ignorefunc = None
23 self.ignorefunc = None
25 self._slash = None
24 self._slash = None
26
25
@@ -47,6 +46,11 b' class dirstate(object):'
47 except IOError, err:
46 except IOError, err:
48 if err.errno != errno.ENOENT: raise
47 if err.errno != errno.ENOENT: raise
49 return self.pl
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 else:
54 else:
51 raise AttributeError, name
55 raise AttributeError, name
52
56
@@ -256,24 +260,16 b' class dirstate(object):'
256 def copies(self):
260 def copies(self):
257 return self.copymap
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 def updatedirs(self, path, delta):
263 def updatedirs(self, path, delta):
266 if self.dirs is not None:
264 for c in strutil.findall(path, '/'):
267 for c in strutil.findall(path, '/'):
265 pc = path[:c]
268 pc = path[:c]
266 self.dirs.setdefault(pc, 0)
269 self.dirs.setdefault(pc, 0)
267 self.dirs[pc] += delta
270 self.dirs[pc] += delta
271
268
272 def checkinterfering(self, files):
269 def checkinterfering(self, files):
273 def prefixes(f):
270 def prefixes(f):
274 for c in strutil.rfindall(f, '/'):
271 for c in strutil.rfindall(f, '/'):
275 yield f[:c]
272 yield f[:c]
276 self.initdirs()
277 seendirs = {}
273 seendirs = {}
278 for f in files:
274 for f in files:
279 # shadows
275 # shadows
@@ -301,7 +297,6 b' class dirstate(object):'
301 if not files: return
297 if not files: return
302 self.markdirty()
298 self.markdirty()
303 if state == "a":
299 if state == "a":
304 self.initdirs()
305 self.checkinterfering(files)
300 self.checkinterfering(files)
306 for f in files:
301 for f in files:
307 if state == "r":
302 if state == "r":
@@ -320,7 +315,6 b' class dirstate(object):'
320 def forget(self, files):
315 def forget(self, files):
321 if not files: return
316 if not files: return
322 self.markdirty()
317 self.markdirty()
323 self.initdirs()
324 for f in files:
318 for f in files:
325 try:
319 try:
326 del self.map[f]
320 del self.map[f]
General Comments 0
You need to be logged in to leave comments. Login now