# HG changeset patch # User Martin von Zweigbergk # Date 1495123477 25200 # Node ID 23c9a2a71c6e3ca3983554b1538dc22ac55a0154 # Parent 7df259077d4b2b0a25bceab28bda0ea3c5643f79 match: make _fileroots a @propertycache and rename it to _fileset The files in the set are not necesserily roots of anything. Making it a @propertycache will help towards extracting a base class for matchers. diff -r 7df259077d4b -r 23c9a2a71c6e hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py Wed May 17 23:54:43 2017 -0700 +++ b/hgext/largefiles/overrides.py Thu May 18 09:04:37 2017 -0700 @@ -41,7 +41,7 @@ m = copy.copy(match) lfile = lambda f: lfutil.standin(f) in manifest m._files = filter(lfile, m._files) - m._fileroots = set(m._files) + m._fileset = set(m._files) m._always = False origmatchfn = m.matchfn m.matchfn = lambda f: lfile(f) and origmatchfn(f) @@ -56,7 +56,7 @@ notlfile = lambda f: not (lfutil.isstandin(f) or lfutil.standin(f) in manifest or f in excluded) m._files = filter(notlfile, m._files) - m._fileroots = set(m._files) + m._fileset = set(m._files) m._always = False origmatchfn = m.matchfn m.matchfn = lambda f: notlfile(f) and origmatchfn(f) @@ -368,7 +368,7 @@ elif m._files[i] not in ctx and repo.wvfs.isdir(standin): m._files.append(standin) - m._fileroots = set(m._files) + m._fileset = set(m._files) m._always = False origmatchfn = m.matchfn def lfmatchfn(f): @@ -644,7 +644,7 @@ m = copy.copy(match) lfile = lambda f: lfutil.standin(f) in manifest m._files = [lfutil.standin(f) for f in m._files if lfile(f)] - m._fileroots = set(m._files) + m._fileset = set(m._files) origmatchfn = m.matchfn def matchfn(f): lfile = lfutil.splitstandin(f) @@ -767,7 +767,7 @@ else: matchfiles.append(f) m._files = matchfiles - m._fileroots = set(m._files) + m._fileset = set(m._files) origmatchfn = m.matchfn def matchfn(f): lfile = lfutil.splitstandin(f) diff -r 7df259077d4b -r 23c9a2a71c6e mercurial/match.py --- a/mercurial/match.py Wed May 17 23:54:43 2017 -0700 +++ b/mercurial/match.py Thu May 18 09:04:37 2017 -0700 @@ -188,7 +188,6 @@ return True self.matchfn = m - self._fileroots = set(self._files) def __call__(self, fn): return self.matchfn(fn) @@ -235,8 +234,12 @@ return self._files @propertycache + def _fileset(self): + return set(self._files) + + @propertycache def _dirs(self): - return set(util.dirs(self._fileroots)) | {'.'} + return set(util.dirs(self._fileset)) | {'.'} def visitdir(self, dir): '''Decides whether a directory should be visited based on whether it @@ -250,7 +253,7 @@ This function's behavior is undefined if it has returned False for one of the dir's parent directories. ''' - if self.prefix() and dir in self._fileroots: + if self.prefix() and dir in self._fileset: return 'all' if dir in self._excluderoots: return False @@ -261,16 +264,16 @@ not any(parent in self._includeroots for parent in util.finddirs(dir))): return False - return (not self._fileroots or - '.' in self._fileroots or - dir in self._fileroots or + return (not self._fileset or + '.' in self._fileset or + dir in self._fileset or dir in self._dirs or - any(parentdir in self._fileroots + any(parentdir in self._fileset for parentdir in util.finddirs(dir))) def exact(self, f): '''Returns True if f is in .files().''' - return f in self._fileroots + return f in self._fileset def anypats(self): '''Matcher uses patterns or include/exclude.''' @@ -399,7 +402,6 @@ return matcher.visitdir(self._path) return matcher.visitdir(self._path + "/" + dir) self.visitdir = visitdir - self._fileroots = set(self._files) def abs(self, f): return self._matcher.abs(self._path + "/" + f) @@ -428,8 +430,8 @@ # inexact case matches are treated as exact, and not noted without -v. if self._files: roots, dirs = _rootsanddirs(self._kp) - self._fileroots = set(roots) - self._fileroots.update(dirs) + self._fileset = set(roots) + self._fileset.update(dirs) def _normalize(self, patterns, default, root, cwd, auditor): self._kp = super(icasefsmatcher, self)._normalize(patterns, default,