diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1427,6 +1427,18 @@ class workingctx(committablectx): finally: wlock.release() + def match(self, pats=[], include=None, exclude=None, default='glob'): + r = self._repo + + # Only a case insensitive filesystem needs magic to translate user input + # to actual case in the filesystem. + if not util.checkcase(r.root): + return matchmod.icasefsmatcher(r.root, r.getcwd(), pats, include, + exclude, default, r.auditor, self) + return matchmod.match(r.root, r.getcwd(), pats, + include, exclude, default, + auditor=r.auditor, ctx=self) + def _filtersuspectsymlink(self, files): if not files or self._repo.dirstate._checklink: return files diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -273,6 +273,34 @@ class narrowmatcher(match): def rel(self, f): return self._matcher.rel(self._path + "/" + f) +class icasefsmatcher(match): + """A matcher for wdir on case insensitive filesystems, which normalizes the + given patterns to the case in the filesystem. + """ + + def __init__(self, root, cwd, patterns, include, exclude, default, auditor, + ctx): + init = super(icasefsmatcher, self).__init__ + self._dsnormalize = ctx.repo().dirstate.normalize + + init(root, cwd, patterns, include, exclude, default, auditor=auditor, + ctx=ctx) + + # m.exact(file) must be based off of the actual user input, otherwise + # inexact case matches are treated as exact, and not noted without -v. + if self._files: + self._fmap = set(_roots(self._kp)) + + def _normalize(self, patterns, default, root, cwd, auditor): + self._kp = super(icasefsmatcher, self)._normalize(patterns, default, + root, cwd, auditor) + kindpats = [] + for kind, pats in self._kp: + if kind not in ('re', 'relre'): # regex can't be normalized + pats = self._dsnormalize(pats) + kindpats.append((kind, pats)) + return kindpats + def patkind(pattern, default=None): '''If pattern is 'kind:pat' with a known kind, return kind.''' return _patsplit(pattern, default)[0] diff --git a/tests/test-add.t b/tests/test-add.t --- a/tests/test-add.t +++ b/tests/test-add.t @@ -176,12 +176,48 @@ Test that adding a directory doesn't req $ mkdir CapsDir1/CapsDir/SubDir $ echo def > CapsDir1/CapsDir/SubDir/Def.txt - $ hg add -v capsdir1/capsdir + $ hg add capsdir1/capsdir adding CapsDir1/CapsDir/AbC.txt (glob) adding CapsDir1/CapsDir/SubDir/Def.txt (glob) $ hg forget capsdir1/capsdir/abc.txt removing CapsDir1/CapsDir/AbC.txt (glob) + + $ hg forget capsdir1/capsdir + removing CapsDir1/CapsDir/SubDir/Def.txt (glob) + + $ hg add capsdir1 + adding CapsDir1/CapsDir/AbC.txt (glob) + adding CapsDir1/CapsDir/SubDir/Def.txt (glob) + + $ hg ci -m "AbCDef" capsdir1/capsdir + + $ hg status -A capsdir1/capsdir + C CapsDir1/CapsDir/AbC.txt + C CapsDir1/CapsDir/SubDir/Def.txt + + $ hg files capsdir1/capsdir + CapsDir1/CapsDir/AbC.txt (glob) + CapsDir1/CapsDir/SubDir/Def.txt (glob) + + $ echo xyz > CapsDir1/CapsDir/SubDir/Def.txt + $ hg ci -m xyz capsdir1/capsdir/subdir/def.txt + + $ hg revert -r '.^' capsdir1/capsdir + reverting CapsDir1/CapsDir/SubDir/Def.txt (glob) + + $ hg diff capsdir1/capsdir + diff -r 5112e00e781d CapsDir1/CapsDir/SubDir/Def.txt + --- a/CapsDir1/CapsDir/SubDir/Def.txt Thu Jan 01 00:00:00 1970 +0000 + +++ b/CapsDir1/CapsDir/SubDir/Def.txt * +0000 (glob) + @@ -1,1 +1,1 @@ + -xyz + +def + + $ hg remove -f 'glob:**.txt' -X capsdir1/capsdir + $ hg remove -f 'glob:**.txt' -I capsdir1/capsdir + removing CapsDir1/CapsDir/AbC.txt (glob) + removing CapsDir1/CapsDir/SubDir/Def.txt (glob) #endif $ cd ..