##// END OF EJS Templates
revset: pass in lookup function instead of repo (API)...
Yuya Nishihara -
r37913:f83cb91b default
parent child Browse files
Show More
@@ -276,7 +276,8 b' def _search(web):'
276 if not funcsused.issubset(revset.safesymbols):
276 if not funcsused.issubset(revset.safesymbols):
277 return MODE_KEYWORD, query
277 return MODE_KEYWORD, query
278
278
279 mfunc = revset.match(web.repo.ui, revdef, repo=web.repo)
279 mfunc = revset.match(web.repo.ui, revdef,
280 lookup=revset.lookupfn(web.repo))
280 try:
281 try:
281 revs = mfunc(web.repo)
282 revs = mfunc(web.repo)
282 return MODE_REVSET, revs
283 return MODE_REVSET, revs
@@ -905,7 +905,8 b' class localrepository(object):'
905 ``{name: definitionstring}``.
905 ``{name: definitionstring}``.
906 '''
906 '''
907 if user:
907 if user:
908 m = revset.matchany(self.ui, specs, repo=self,
908 m = revset.matchany(self.ui, specs,
909 lookup=revset.lookupfn(self),
909 localalias=localalias)
910 localalias=localalias)
910 else:
911 else:
911 m = revset.matchany(None, specs, localalias=localalias)
912 m = revset.matchany(None, specs, localalias=localalias)
@@ -2169,14 +2169,17 b' methods = {'
2169 def lookupfn(repo):
2169 def lookupfn(repo):
2170 return lambda symbol: scmutil.isrevsymbol(repo, symbol)
2170 return lambda symbol: scmutil.isrevsymbol(repo, symbol)
2171
2171
2172 def match(ui, spec, repo=None):
2172 def match(ui, spec, lookup=None):
2173 """Create a matcher for a single revision spec"""
2173 """Create a matcher for a single revision spec"""
2174 return matchany(ui, [spec], repo=repo)
2174 return matchany(ui, [spec], lookup=None)
2175
2175
2176 def matchany(ui, specs, repo=None, localalias=None):
2176 def matchany(ui, specs, lookup=None, localalias=None):
2177 """Create a matcher that will include any revisions matching one of the
2177 """Create a matcher that will include any revisions matching one of the
2178 given specs
2178 given specs
2179
2179
2180 If lookup function is not None, the parser will first attempt to handle
2181 old-style ranges, which may contain operator characters.
2182
2180 If localalias is not None, it is a dict {name: definitionstring}. It takes
2183 If localalias is not None, it is a dict {name: definitionstring}. It takes
2181 precedence over [revsetalias] config section.
2184 precedence over [revsetalias] config section.
2182 """
2185 """
@@ -2186,9 +2189,6 b' def matchany(ui, specs, repo=None, local'
2186 return mfunc
2189 return mfunc
2187 if not all(specs):
2190 if not all(specs):
2188 raise error.ParseError(_("empty query"))
2191 raise error.ParseError(_("empty query"))
2189 lookup = None
2190 if repo:
2191 lookup = lookupfn(repo)
2192 if len(specs) == 1:
2192 if len(specs) == 1:
2193 tree = revsetlang.parse(specs[0], lookup)
2193 tree = revsetlang.parse(specs[0], lookup)
2194 else:
2194 else:
@@ -522,7 +522,7 b' def revset(context, mapping, args):'
522 repo = ctx.repo()
522 repo = ctx.repo()
523
523
524 def query(expr):
524 def query(expr):
525 m = revsetmod.match(repo.ui, expr, repo=repo)
525 m = revsetmod.match(repo.ui, expr, lookup=revsetmod.lookupfn(repo))
526 return m(repo)
526 return m(repo)
527
527
528 if len(args) > 1:
528 if len(args) > 1:
@@ -60,7 +60,7 b" these predicates use '\\0' as a separator"
60 > opttree = revsetlang.optimize(revsetlang.analyze(tree))
60 > opttree = revsetlang.optimize(revsetlang.analyze(tree))
61 > ui.note(b"* optimized:\n", revsetlang.prettyformat(opttree),
61 > ui.note(b"* optimized:\n", revsetlang.prettyformat(opttree),
62 > b"\n")
62 > b"\n")
63 > func = revset.match(ui, expr, repo)
63 > func = revset.match(ui, expr, lookup=revset.lookupfn(repo))
64 > revs = func(repo)
64 > revs = func(repo)
65 > if ui.verbose:
65 > if ui.verbose:
66 > ui.note(b"* set:\n", smartset.prettyformat(revs), b"\n")
66 > ui.note(b"* set:\n", smartset.prettyformat(revs), b"\n")
General Comments 0
You need to be logged in to leave comments. Login now