##// END OF EJS Templates
Add a normalize() method to dirstate...
Paul Moore -
r6677:9865e15f default
parent child Browse files
Show More
@@ -31,6 +31,13 class dirstate(object):
31 31 elif name == '_copymap':
32 32 self._read()
33 33 return self._copymap
34 elif name == '_foldmap':
35 _foldmap = {}
36 for name in self._map:
37 norm = os.path.normcase(os.path.normpath(name))
38 _foldmap[norm] = name
39 self._foldmap = _foldmap
40 return self._foldmap
34 41 elif name == '_branch':
35 42 try:
36 43 self._branch = (self._opener("branch").read().strip()
@@ -69,6 +76,12 class dirstate(object):
69 76 elif name == '_folding':
70 77 self._folding = not util.checkfolding(self._join('.hg'))
71 78 return self._folding
79 elif name == 'normalize':
80 if self._folding:
81 self.normalize = self._normalize
82 else:
83 self.normalize = lambda x: x
84 return self.normalize
72 85 else:
73 86 raise AttributeError, name
74 87
@@ -167,7 +180,7 class dirstate(object):
167 180 dmap[f] = e # we hold onto e[4] because making a subtuple is slow
168 181
169 182 def invalidate(self):
170 for a in "_map _copymap _branch _pl _dirs _ignore".split():
183 for a in "_map _copymap _foldmap _branch _pl _dirs _ignore".split():
171 184 if a in self.__dict__:
172 185 delattr(self, a)
173 186 self._dirty = False
@@ -320,6 +333,16 class dirstate(object):
320 333 except KeyError:
321 334 self._ui.warn(_("not in dirstate: %s\n") % f)
322 335
336 def _normalize(self, path):
337 normpath = os.path.normcase(os.path.normpath(path))
338 if normpath in self._foldmap:
339 return self._foldmap[normpath]
340 elif os.path.exists(path):
341 self._foldmap[normpath] = util.fspath(path, self._root)
342 return self._foldmap[normpath]
343 else:
344 return path
345
323 346 def clear(self):
324 347 self._map = {}
325 348 if "_dirs" in self.__dict__:
@@ -561,7 +584,7 class dirstate(object):
561 584 known[nf] = 1
562 585 if match(nf):
563 586 if supported(ff, st.st_mode, verbose=True):
564 yield 'f', nf, st
587 yield 'f', self.normalize(nf), st
565 588 elif ff in dc:
566 589 yield 'm', nf, st
567 590
General Comments 0
You need to be logged in to leave comments. Login now