merge with stable
authorMatt Mackall <mpm@selenic.com>
Wed, 23 Mar 2011 09:20:40 -0500
changeset 13728 15d1db2abfcb
parent 13727 ce47a0c10224 (current diff)
parent 13725 6783f47d90dd (diff)
child 13729 4a9c09239ba1
merge with stable
hgext/mq.py
mercurial/dirstate.py
mercurial/merge.py
--- a/hgext/mq.py	Tue Mar 22 21:27:51 2011 -0500
+++ b/hgext/mq.py	Wed Mar 23 09:20:40 2011 -0500
@@ -2383,7 +2383,7 @@
     When -f/--force is applied, all local changes in patched files
     will be lost.
 
-    Return 0 on succces.
+    Return 0 on success.
     """
     q = repo.mq
     mergeq = None
--- a/mercurial/dirstate.py	Tue Mar 22 21:27:51 2011 -0500
+++ b/mercurial/dirstate.py	Wed Mar 23 09:20:40 2011 -0500
@@ -375,16 +375,34 @@
             self._ui.warn(_("not in dirstate: %s\n") % f)
         self._lastnormal.discard(f)
 
-    def _normalize(self, path, knownpath):
-        norm_path = os.path.normcase(path)
-        fold_path = self._foldmap.get(norm_path, None)
-        if fold_path is None:
-            if knownpath or not os.path.lexists(os.path.join(self._root, path)):
-                fold_path = path
+    def _normalize(self, path, isknown):
+        normed = os.path.normcase(path)
+        folded = self._foldmap.get(normed, None)
+        if folded is None:
+            if isknown or not os.path.lexists(os.path.join(self._root, path)):
+                folded = path
             else:
-                fold_path = self._foldmap.setdefault(norm_path,
+                folded = self._foldmap.setdefault(normed,
                                 util.fspath(path, self._root))
-        return fold_path
+        return folded
+
+    def normalize(self, path, isknown=False):
+        '''
+        normalize the case of a pathname when on a casefolding filesystem
+
+        isknown specifies whether the filename came from walking the
+        disk, to avoid extra filesystem access
+
+        The normalized case is determined based on the following precedence:
+
+        - version of name already stored in the dirstate
+        - version of name stored on disk
+        - version provided via command arguments
+        '''
+
+        if self._checkcase:
+            return self._normalize(path, isknown)
+        return path
 
     def clear(self):
         self._map = {}
--- a/mercurial/merge.py	Tue Mar 22 21:27:51 2011 -0500
+++ b/mercurial/merge.py	Wed Mar 23 09:20:40 2011 -0500
@@ -338,7 +338,8 @@
                 else:
                     merged += 1
             util.set_flags(repo.wjoin(fd), 'l' in flags, 'x' in flags)
-            if f != fd and move and os.path.lexists(repo.wjoin(f)):
+            if (move and repo.dirstate.normalize(fd) != f
+                and os.path.lexists(repo.wjoin(f))):
                 repo.ui.debug("removing %s\n" % f)
                 os.unlink(repo.wjoin(f))
         elif m == "g": # get