[PATCH 3 of 6] scmutil: add utility function to examine case-folding collision exactly

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Nov 14 10:07:59 CST 2013


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1384438902 -32400
#      Thu Nov 14 23:21:42 2013 +0900
# Node ID 284ca308c2eb1db65021f94c1c9c0a93b5f84650
# Parent  8d55541fd42a8bd9ea4fec42b42c89b7dea6cfb8
scmutil: add utility function to examine case-folding collision exactly

This patch adds "casecollisionauditor._exact()" to examine whether
"self._loweredfiles" contains files only really existing or not.

If so, it immediately returns True. Otherwise, it re-builds
"self._loweredfiles" without removed files and returns False.

Files in "self._newfiles" are also used for re-building, because they
may not be added into dirstate yet.

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -90,6 +90,7 @@
         self._abort = abort
         allfiles = '\0'.join(dirstate._map)
         self._loweredfiles = set(encoding.lower(allfiles).split('\0'))
+        self._existingonly = False
         self._dirstate = dirstate
         # The purpose of _newfiles is so that we don't complain about
         # case collisions if someone were to call this object with the
@@ -111,6 +112,20 @@
             raise util.Abort(msg)
         self._ui.warn(_("warning: %s\n") % msg)
 
+    def _exact(self):
+        if self._existingonly:
+            return True
+        existing = []
+        for f, s in self._dirstate.iteritems():
+            if s[0] != 'r':
+                existing.append(f)
+        for f in self._newfiles:
+            existing.append(f)
+        allfiles = '\0'.join(existing)
+        self._loweredfiles = set(encoding.lower(allfiles).split('\0'))
+        self._existingonly = True
+        return False
+
 class pathauditor(object):
     '''ensure that a filesystem path contains no banned components.
     the following properties of a path are checked:


More information about the Mercurial-devel mailing list