[PATCH 2 of 8] Add a method to dirstate to return case folding state

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


# HG changeset patch
# User "Paul Moore <p.f.moore at gmail.com>"
# Date 1209573926 -3600
# Node ID 10e29dda3add46953b62a4b5ab01bdfe7de437ea
# Parent  4c332d2df388086257be74380d53701631fd3a2e
Add a method to dirstate to return case folding state

This patch adds a method to the dirstate to check if the directory is on a
casr folding filesystem. The result of the check is cached, so that it is
computed only once per Mercurial invocation. It assumes that the whole
dirstate is on the same filesystem (or at least that the case folding
behaviour does not change across the whole dirstate).

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -66,11 +66,19 @@
         elif name == '_checkexec':
             self._checkexec = util.checkexec(self._root)
             return self._checkexec
+        elif name == '_casefold':
+            self._casefold = not util.checkfolding(self._join('.hg'))
+            return self._casefold
         else:
             raise AttributeError, name
 
     def _join(self, f):
         return os.path.join(self._root, f)
+
+    def casefold(self):
+        '''True if the working directory is on a filesystem that folds case.
+        Assumed to be invariant over the whole working directory.'''
+        return self._casefold
 
     def getcwd(self):
         cwd = os.getcwd()


More information about the Mercurial-devel mailing list