2167 } |
2167 } |
2168 |
2168 |
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 |
|
2180 If lookup function is not None, the parser will first attempt to handle |
|
2181 old-style ranges, which may contain operator characters. |
2179 |
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 """ |
2183 if not specs: |
2186 if not specs: |
2184 def mfunc(repo, subset=None): |
2187 def mfunc(repo, subset=None): |
2185 return baseset() |
2188 return baseset() |
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: |
2195 tree = ('or', |
2195 tree = ('or', |
2196 ('list',) + tuple(revsetlang.parse(s, lookup) for s in specs)) |
2196 ('list',) + tuple(revsetlang.parse(s, lookup) for s in specs)) |