[PATCH 6 of 8] Fix for issue 1083 (Case collision error between different revisions ...)

Paul Moore p.f.moore at gmail.com
Wed Apr 30 12:37:28 CDT 2008


# HG changeset patch
# User "Paul Moore <p.f.moore at gmail.com>"
# Date 1209573981 -3600
# Node ID 79a53e5328ec7da90c7048b8e894bd4e28075b76
# Parent  114727a7ad5604c8c31324ebb431b372eec73061
Fix for issue 1083 (Case collision error between different revisions ...)

Fixed by ensuring that localrepo.filecommit correctly detects files renamed in
such a way that the names only differ in case. The filecommit function relies
on self.wread(fn) failing with an IO error if the file no longer exists. On
case insensitive systems, this isn't true for case-only name changes. Fixed by
adding an explicit check for the file existing with the specified case.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -679,11 +679,22 @@
         self._wlockref = weakref.ref(l)
         return l
 
+    def testcase(self, fn):
+        """Raise IOError if fn doesn't exist with this exact case"""
+
+        # Check that the file exists in a case sensitive manner - it may be
+        # stored in the filesystem in a different case than the name passed in
+        # (on case insensitive filesystems).
+        if util.fspath(fn, self.root, default='') != fn:
+            raise IOError(errno.ENOENT, fn)
+
     def filecommit(self, fn, manifest1, manifest2, linkrev, tr, changelist):
         """
         commit an individual file as part of a larger transaction
         """
 
+	if self.dirstate.casefold():
+            self.testcase(fn)
         t = self.wread(fn)
         fl = self.file(fn)
         fp1 = manifest1.get(fn, nullid)


More information about the Mercurial-devel mailing list