Patchwork util: rename checkcase() to fscasesensitive() (API)

login
register
mail settings
Submitter via Mercurial-devel
Date Aug. 30, 2016, 4:33 p.m.
Message ID <710794310d9d85f5d508.1472574819@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/16483/
State Accepted
Headers show

Comments

via Mercurial-devel - Aug. 30, 2016, 4:33 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1472574173 25200
#      Tue Aug 30 09:22:53 2016 -0700
# Node ID 710794310d9d85f5d5085ce294e2d5cdfcf25c68
# Parent  58db005d870ea22f650b13e01467777816bebfa2
util: rename checkcase() to fscasesensitive() (API)

I always read the name "checkcase(path)" as "do we need to check for
case folding at this path", but it's actually (I think) meant to be
read "check if the file system cares about case at this path". I'm
clearly not the only one confused by this as the dirstate has this
property:

  def _checkcase(self):
      return not util.checkcase(self._join('.hg'))

Maybe we should even inverse the function and call it fscasefolding()
since that's what all callers care about?
Yuya Nishihara - Sept. 2, 2016, 2:11 p.m.
On Tue, 30 Aug 2016 09:33:39 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1472574173 25200
> #      Tue Aug 30 09:22:53 2016 -0700
> # Node ID 710794310d9d85f5d5085ce294e2d5cdfcf25c68
> # Parent  58db005d870ea22f650b13e01467777816bebfa2
> util: rename checkcase() to fscasesensitive() (API)

Sure, queued this, thanks.

> I always read the name "checkcase(path)" as "do we need to check for
> case folding at this path", but it's actually (I think) meant to be
> read "check if the file system cares about case at this path". I'm
> clearly not the only one confused by this as the dirstate has this
> property:
> 
>   def _checkcase(self):
>       return not util.checkcase(self._join('.hg'))
> 
> Maybe we should even inverse the function and call it fscasefolding()
> since that's what all callers care about?

I have no preference. Both of them sound better than checkcase().

Patch

diff -r 58db005d870e -r 710794310d9d hgext/win32mbcs.py
--- a/hgext/win32mbcs.py	Fri Aug 26 00:16:51 2016 +0000
+++ b/hgext/win32mbcs.py	Tue Aug 30 09:22:53 2016 -0700
@@ -148,8 +148,8 @@ 
 # NOTE: os.path.dirname() and os.path.basename() are safe because
 #       they use result of os.path.split()
 funcs = '''os.path.join os.path.split os.path.splitext
- os.path.normpath os.makedirs
- mercurial.util.endswithsep mercurial.util.splitpath mercurial.util.checkcase
+ os.path.normpath os.makedirs mercurial.util.endswithsep
+ mercurial.util.splitpath mercurial.util.fscasesensitive
  mercurial.util.fspath mercurial.util.pconvert mercurial.util.normpath
  mercurial.util.checkwinfilename mercurial.util.checkosfilename
  mercurial.util.split'''
diff -r 58db005d870e -r 710794310d9d mercurial/commands.py
--- a/mercurial/commands.py	Fri Aug 26 00:16:51 2016 +0000
+++ b/mercurial/commands.py	Tue Aug 30 09:22:53 2016 -0700
@@ -2449,7 +2449,7 @@ 
     ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
     ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
     ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
-    ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
+    ui.write(('case-sensitive: %s\n') % (util.fscasesensitive('.debugfsinfo')
                                 and 'yes' or 'no'))
     os.unlink('.debugfsinfo')
 
diff -r 58db005d870e -r 710794310d9d mercurial/context.py
--- a/mercurial/context.py	Fri Aug 26 00:16:51 2016 +0000
+++ b/mercurial/context.py	Tue Aug 30 09:22:53 2016 -0700
@@ -1501,7 +1501,7 @@ 
 
         # Only a case insensitive filesystem needs magic to translate user input
         # to actual case in the filesystem.
-        if not util.checkcase(r.root):
+        if not util.fscasesensitive(r.root):
             return matchmod.icasefsmatcher(r.root, r.getcwd(), pats, include,
                                            exclude, default, r.auditor, self,
                                            listsubrepos=listsubrepos,
diff -r 58db005d870e -r 710794310d9d mercurial/dirstate.py
--- a/mercurial/dirstate.py	Fri Aug 26 00:16:51 2016 +0000
+++ b/mercurial/dirstate.py	Tue Aug 30 09:22:53 2016 -0700
@@ -227,7 +227,7 @@ 
 
     @propertycache
     def _checkcase(self):
-        return not util.checkcase(self._join('.hg'))
+        return not util.fscasesensitive(self._join('.hg'))
 
     def _join(self, f):
         # much faster than os.path.join()
diff -r 58db005d870e -r 710794310d9d mercurial/merge.py
--- a/mercurial/merge.py	Fri Aug 26 00:16:51 2016 +0000
+++ b/mercurial/merge.py	Tue Aug 30 09:22:53 2016 -0700
@@ -1586,7 +1586,7 @@ 
                 actions[m] = []
             actions[m].append((f, args, msg))
 
-        if not util.checkcase(repo.path):
+        if not util.fscasesensitive(repo.path):
             # check collision between files only in p2 for clean update
             if (not branchmerge and
                 (force or not wc.dirty(missing=True, branch=False))):
diff -r 58db005d870e -r 710794310d9d mercurial/pathutil.py
--- a/mercurial/pathutil.py	Fri Aug 26 00:16:51 2016 +0000
+++ b/mercurial/pathutil.py	Tue Aug 30 09:22:53 2016 -0700
@@ -40,7 +40,7 @@ 
         self.root = root
         self._realfs = realfs
         self.callback = callback
-        if os.path.lexists(root) and not util.checkcase(root):
+        if os.path.lexists(root) and not util.fscasesensitive(root):
             self.normcase = util.normcase
         else:
             self.normcase = lambda x: x
diff -r 58db005d870e -r 710794310d9d mercurial/util.py
--- a/mercurial/util.py	Fri Aug 26 00:16:51 2016 +0000
+++ b/mercurial/util.py	Tue Aug 30 09:22:53 2016 -0700
@@ -1213,7 +1213,7 @@ 
 
 # File system features
 
-def checkcase(path):
+def fscasesensitive(path):
     """
     Return true if the given path is on a case-sensitive filesystem