[PATCH 3 of 3] Add a normalize() method to dirstate
Paul Moore
p.f.moore at gmail.com
Wed May 21 16:49:03 CDT 2008
# HG changeset patch
# User "Paul Moore <p.f.moore at gmail.com>"
# Date 1211406493 -3600
# Node ID 657c5188d7af6a9215427548943f12bfe0d3022c
# Parent 025ba311a38a094fac501ccf81c5aaa62e895466
Add a normalize() method to dirstate
This method returns the normalised form of a path. This is
- the form in the dirstate, if available, or
- the form on disk, if available, or
- the form passed on the command line
normalize() is called on the type-'f' result of statwalk.
This fixes issues 910 and 1092
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -23,6 +23,7 @@
self._dirty = False
self._dirtypl = False
self._ui = ui
+ self._folded = {} # Cache of folded pathnames
def __getattr__(self, name):
if name == '_map':
@@ -320,6 +321,16 @@
except KeyError:
self._ui.warn(_("not in dirstate: %s\n") % f)
+ def normalize(self, path):
+ if not self._folding or path in self._map:
+ return path
+ elif path in self._folded:
+ return self._folded[path]
+ elif os.path.exists(path):
+ return self._folded.setdefault(path, util.fspath(path, self._root))
+ else:
+ return path
+
def clear(self):
self._map = {}
if "_dirs" in self.__dict__:
@@ -561,7 +572,7 @@
known[nf] = 1
if match(nf):
if supported(ff, st.st_mode, verbose=True):
- yield 'f', nf, st
+ yield 'f', self.normalize(nf), st
elif ff in dc:
yield 'm', nf, st
More information about the Mercurial-devel
mailing list