##// END OF EJS Templates
dirstate: hide some more internals
Matt Mackall -
r4615:9b00b73a default
parent child Browse files
Show More
@@ -25,10 +25,10 b' class dirstate(object):'
25
25
26 def __getattr__(self, name):
26 def __getattr__(self, name):
27 if name == '_map':
27 if name == '_map':
28 self.read()
28 self._read()
29 return self._map
29 return self._map
30 elif name == '_copymap':
30 elif name == '_copymap':
31 self.read()
31 self._read()
32 return self._copymap
32 return self._copymap
33 elif name == '_branch':
33 elif name == '_branch':
34 try:
34 try:
@@ -46,11 +46,11 b' class dirstate(object):'
46 except IOError, err:
46 except IOError, err:
47 if err.errno != errno.ENOENT: raise
47 if err.errno != errno.ENOENT: raise
48 return self._pl
48 return self._pl
49 elif name == 'dirs':
49 elif name == '_dirs':
50 self.dirs = {}
50 self._dirs = {}
51 for f in self._map:
51 for f in self._map:
52 self.updatedirs(f, 1)
52 self._incpath(f)
53 return self.dirs
53 return self._dirs
54 elif name == '_ignore':
54 elif name == '_ignore':
55 files = [self.wjoin('.hgignore')] + self._ui.hgignorefiles()
55 files = [self.wjoin('.hgignore')] + self._ui.hgignorefiles()
56 self._ignore = ignore.ignore(self._root, files, self._ui.warn)
56 self._ignore = ignore.ignore(self._root, files, self._ui.warn)
@@ -120,7 +120,7 b' class dirstate(object):'
120 def state(self, key):
120 def state(self, key):
121 return self._map.get(key, ("?",))[0]
121 return self._map.get(key, ("?",))[0]
122
122
123 def read(self):
123 def _read(self):
124 self._map = {}
124 self._map = {}
125 self._copymap = {}
125 self._copymap = {}
126 self._pl = [nullid, nullid]
126 self._pl = [nullid, nullid]
@@ -156,7 +156,7 b' class dirstate(object):'
156 pos = newpos
156 pos = newpos
157
157
158 def invalidate(self):
158 def invalidate(self):
159 for a in "_map _copymap _branch pl dirs _ignore".split():
159 for a in "_map _copymap _branch pl _dirs _ignore".split():
160 if hasattr(self, a):
160 if hasattr(self, a):
161 self.__delattr__(a)
161 self.__delattr__(a)
162
162
@@ -170,11 +170,17 b' class dirstate(object):'
170 def copies(self):
170 def copies(self):
171 return self._copymap
171 return self._copymap
172
172
173 def updatedirs(self, path, delta):
173 def _incpath(self, path):
174 for c in strutil.findall(path, '/'):
174 for c in strutil.findall(path, '/'):
175 pc = path[:c]
175 pc = path[:c]
176 self.dirs.setdefault(pc, 0)
176 self._dirs.setdefault(pc, 0)
177 self.dirs[pc] += delta
177 self._dirs[pc] += 1
178
179 def _decpath(self, path):
180 for c in strutil.findall(path, '/'):
181 pc = path[:c]
182 self._dirs.setdefault(pc, 0)
183 self._dirs[pc] -= 1
178
184
179 def checkinterfering(self, files):
185 def checkinterfering(self, files):
180 def prefixes(f):
186 def prefixes(f):
@@ -183,7 +189,7 b' class dirstate(object):'
183 seendirs = {}
189 seendirs = {}
184 for f in files:
190 for f in files:
185 # shadows
191 # shadows
186 if self.dirs.get(f):
192 if self._dirs.get(f):
187 raise util.Abort(_('directory named %r already in dirstate') %
193 raise util.Abort(_('directory named %r already in dirstate') %
188 f)
194 f)
189 for d in prefixes(f):
195 for d in prefixes(f):
@@ -211,10 +217,10 b' class dirstate(object):'
211 for f in files:
217 for f in files:
212 if state == "r":
218 if state == "r":
213 self._map[f] = ('r', 0, 0, 0)
219 self._map[f] = ('r', 0, 0, 0)
214 self.updatedirs(f, -1)
220 self._decpath(f)
215 else:
221 else:
216 if state == "a":
222 if state == "a":
217 self.updatedirs(f, 1)
223 self._incpath(f)
218 s = os.lstat(self.wjoin(f))
224 s = os.lstat(self.wjoin(f))
219 st_size = kw.get('st_size', s.st_size)
225 st_size = kw.get('st_size', s.st_size)
220 st_mtime = kw.get('st_mtime', s.st_mtime)
226 st_mtime = kw.get('st_mtime', s.st_mtime)
@@ -228,7 +234,7 b' class dirstate(object):'
228 for f in files:
234 for f in files:
229 try:
235 try:
230 del self._map[f]
236 del self._map[f]
231 self.updatedirs(f, -1)
237 self._decpath(f)
232 except KeyError:
238 except KeyError:
233 self._ui.warn(_("not in dirstate: %s!\n") % f)
239 self._ui.warn(_("not in dirstate: %s!\n") % f)
234 pass
240 pass
@@ -290,7 +296,7 b' class dirstate(object):'
290 bs += 1
296 bs += 1
291 return ret
297 return ret
292
298
293 def supported_type(self, f, st, verbose=False):
299 def _supported(self, f, st, verbose=False):
294 if stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode):
300 if stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode):
295 return True
301 return True
296 if verbose:
302 if verbose:
@@ -383,7 +389,7 b' class dirstate(object):'
383 if imatch(np) and np in dc:
389 if imatch(np) and np in dc:
384 yield 'm', np, st
390 yield 'm', np, st
385 elif imatch(np):
391 elif imatch(np):
386 if self.supported_type(np, st):
392 if self._supported(np, st):
387 yield 'f', np, st
393 yield 'f', np, st
388 elif np in dc:
394 elif np in dc:
389 yield 'm', np, st
395 yield 'm', np, st
@@ -421,7 +427,7 b' class dirstate(object):'
421 yield e
427 yield e
422 else:
428 else:
423 if not seen(nf) and match(nf):
429 if not seen(nf) and match(nf):
424 if self.supported_type(ff, st, verbose=True):
430 if self._supported(ff, st, verbose=True):
425 yield 'f', nf, st
431 yield 'f', nf, st
426 elif ff in dc:
432 elif ff in dc:
427 yield 'm', nf, st
433 yield 'm', nf, st
@@ -458,7 +464,7 b' class dirstate(object):'
458 raise
464 raise
459 st = None
465 st = None
460 # We need to re-check that it is a valid file
466 # We need to re-check that it is a valid file
461 if st and self.supported_type(fn, st):
467 if st and self._supported(fn, st):
462 nonexistent = False
468 nonexistent = False
463 # XXX: what to do with file no longer present in the fs
469 # XXX: what to do with file no longer present in the fs
464 # who are not removed in the dirstate ?
470 # who are not removed in the dirstate ?
General Comments 0
You need to be logged in to leave comments. Login now