Mercurial > hg
comparison mercurial/match.py @ 38612:760cc5dc01e8
fileset: restrict getfileset() to not return a computed set (API)
And rename the functions accordingly. fileset.match() will be changed to
not compute the initial subset.
test-glog*.t get back to the state before 9f9ffe5f687c "match: compose
'set:' pattern as matcher."
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 09 Jun 2018 20:53:12 +0900 |
parents | 0ba4cf3f088f |
children | a8bfaf592033 |
comparison
equal
deleted
inserted
replaced
38611:0ba4cf3f088f | 38612:760cc5dc01e8 |
---|---|
38 # slightly faster, provided by facebook's re2 bindings | 38 # slightly faster, provided by facebook's re2 bindings |
39 return m.test_match | 39 return m.test_match |
40 except AttributeError: | 40 except AttributeError: |
41 return m.match | 41 return m.match |
42 | 42 |
43 def _expandsets(kindpats, ctx, listsubrepos): | 43 def _expandsets(root, cwd, kindpats, ctx, listsubrepos, badfn): |
44 '''Returns the kindpats list with the 'set' patterns expanded.''' | 44 '''Returns the kindpats list with the 'set' patterns expanded to matchers''' |
45 fset = set() | 45 matchers = [] |
46 other = [] | 46 other = [] |
47 | 47 |
48 for kind, pat, source in kindpats: | 48 for kind, pat, source in kindpats: |
49 if kind == 'set': | 49 if kind == 'set': |
50 if not ctx: | 50 if not ctx: |
51 raise error.ProgrammingError("fileset expression with no " | 51 raise error.ProgrammingError("fileset expression with no " |
52 "context") | 52 "context") |
53 s = ctx.getfileset(pat) | 53 matchers.append(ctx.matchfileset(pat, badfn=badfn)) |
54 fset.update(s) | |
55 | 54 |
56 if listsubrepos: | 55 if listsubrepos: |
57 for subpath in ctx.substate: | 56 for subpath in ctx.substate: |
58 s = ctx.sub(subpath).getfileset(pat) | 57 sm = ctx.sub(subpath).matchfileset(pat, badfn=badfn) |
59 fset.update(subpath + '/' + f for f in s) | 58 pm = prefixdirmatcher(root, cwd, subpath, sm, badfn=badfn) |
59 matchers.append(pm) | |
60 | 60 |
61 continue | 61 continue |
62 other.append((kind, pat, source)) | 62 other.append((kind, pat, source)) |
63 return fset, other | 63 return matchers, other |
64 | 64 |
65 def _expandsubinclude(kindpats, root): | 65 def _expandsubinclude(kindpats, root): |
66 '''Returns the list of subinclude matcher args and the kindpats without the | 66 '''Returns the list of subinclude matcher args and the kindpats without the |
67 subincludes in it.''' | 67 subincludes in it.''' |
68 relmatchers = [] | 68 relmatchers = [] |
95 return False | 95 return False |
96 return True | 96 return True |
97 | 97 |
98 def _buildkindpatsmatcher(matchercls, root, cwd, kindpats, ctx=None, | 98 def _buildkindpatsmatcher(matchercls, root, cwd, kindpats, ctx=None, |
99 listsubrepos=False, badfn=None): | 99 listsubrepos=False, badfn=None): |
100 fset, kindpats = _expandsets(kindpats, ctx, listsubrepos) | |
101 matchers = [] | 100 matchers = [] |
101 fms, kindpats = _expandsets(root, cwd, kindpats, ctx=ctx, | |
102 listsubrepos=listsubrepos, badfn=badfn) | |
102 if kindpats: | 103 if kindpats: |
103 m = matchercls(root, cwd, kindpats, listsubrepos=listsubrepos, | 104 m = matchercls(root, cwd, kindpats, listsubrepos=listsubrepos, |
104 badfn=badfn) | 105 badfn=badfn) |
105 matchers.append(m) | 106 matchers.append(m) |
106 if fset: | 107 if fms: |
107 m = predicatematcher(root, cwd, fset.__contains__, | 108 matchers.extend(fms) |
108 predrepr='fileset', badfn=badfn) | |
109 matchers.append(m) | |
110 if not matchers: | 109 if not matchers: |
111 return nevermatcher(root, cwd, badfn=badfn) | 110 return nevermatcher(root, cwd, badfn=badfn) |
112 if len(matchers) == 1: | 111 if len(matchers) == 1: |
113 return matchers[0] | 112 return matchers[0] |
114 return unionmatcher(matchers) | 113 return unionmatcher(matchers) |