Case-folding fix

Matt Mackall mpm at selenic.com
Sun Jun 22 19:42:12 UTC 2008


The following patch fixes some cases where I was able to confuse hg
status.

First, if I had a file named a that I moved to A, hg status A would
show:

A a
A A

Thus, we need to normalize the files returned by findfiles.

We could also confuse things by asking for hg status foo/bar FOO/BAR,
which would give us two sets of results. So we have to normalize the
files we add to the known dict as well.

With these tweaks, I can't seem to fool dirstate any more in my testing
under Wine.

diff -r 683428d1e639 mercurial/dirstate.py
--- a/mercurial/dirstate.py	Wed Jun 18 00:28:40 2008 -0500
+++ b/mercurial/dirstate.py	Sun Jun 22 14:26:58 2008 -0500
@@ -537,9 +537,10 @@
                             continue
                 for f, kind, st in entries:
                     np = pconvert(join(nd, f))
+                    nn = self.normalize(np)
                     if np in known:
                         continue
-                    known[np] = 1
+                    known[nn] = 1
                     p = join(top, f)
                     # don't trip over symlinks
                     if kind == stat.S_IFDIR:
@@ -548,12 +549,12 @@
                             if hasattr(match, 'dir'):
                                 match.dir(np)
                         if np in dc and match(np):
-                            add((np, 'm', st))
+                            add((nn, 'm', st))
                     elif imatch(np):
                         if supported(np, st.st_mode):
-                            add((np, 'f', st))
+                            add((nn, 'f', st))
                         elif np in dc:
-                            add((np, 'm', st))
+                            add((nn, 'm', st))
             found.sort()
             return found
 
@@ -561,6 +562,7 @@
         files.sort()
         for ff in files:
             nf = normpath(ff)
+            nn = self.normalize(nf)
             f = _join(ff)
             try:
                 st = lstat(f)
@@ -581,9 +583,9 @@
                     for f, src, st in findfiles(f):
                         yield src, f, st
             else:
-                if nf in known:
+                if nn in known:
                     continue
-                known[nf] = 1
+                known[nn] = 1
                 if match(nf):
                     if supported(ff, st.st_mode, verbose=True):
                         yield 'f', self.normalize(nf), st

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list