--- a/mercurial/match.py Sat Jan 09 13:22:26 2016 +0900
+++ b/mercurial/match.py Fri Feb 05 21:25:44 2016 -0800
@@ -381,7 +381,16 @@
self._always = any(f == path for f in matcher._files)
self._anypats = matcher._anypats
+ # Some information is lost in the superclass's constructor, so we
+ # can not accurately create the matching function for the subdirectory
+ # from the inputs. Instead, we override matchfn() and visitdir() to
+ # call the original matcher with the subdirectory path prepended.
self.matchfn = lambda fn: matcher.matchfn(self._path + "/" + fn)
+ def visitdir(dir):
+ if dir == '.':
+ return matcher.visitdir(self._path)
+ return matcher.visitdir(self._path + "/" + dir)
+ self.visitdir = visitdir
self._fileroots = set(self._files)
def abs(self, f):