##// END OF EJS Templates
revset: move subscript relation functions to its own dict...
av6 -
r40967:e54bfde9 default
parent child Browse files
Show More
@@ -218,15 +218,7 def notset(repo, subset, x, order):
218 218 def relationset(repo, subset, x, y, order):
219 219 raise error.ParseError(_("can't use a relation in this context"))
220 220
221 def relsubscriptset(repo, subset, x, y, z, order):
222 # this is pretty basic implementation of 'x#y[z]' operator, still
223 # experimental so undocumented. see the wiki for further ideas.
224 # https://www.mercurial-scm.org/wiki/RevsetOperatorPlan
225 rel = getsymbol(y)
226 n = getinteger(z, _("relation subscript must be an integer"))
227
228 # TODO: perhaps this should be a table of relation functions
229 if rel in ('g', 'generations'):
221 def generationsrel(repo, subset, x, rel, n, order):
230 222 # TODO: support range, rewrite tests, and drop startdepth argument
231 223 # from ancestors() and descendants() predicates
232 224 if n <= 0:
@@ -235,7 +227,18 def relsubscriptset(repo, subset, x, y,
235 227 else:
236 228 return _descendants(repo, subset, x, startdepth=n, stopdepth=n + 1)
237 229
238 raise error.UnknownIdentifier(rel, ['generations'])
230 def relsubscriptset(repo, subset, x, y, z, order):
231 # this is pretty basic implementation of 'x#y[z]' operator, still
232 # experimental so undocumented. see the wiki for further ideas.
233 # https://www.mercurial-scm.org/wiki/RevsetOperatorPlan
234 rel = getsymbol(y)
235 n = getinteger(z, _("relation subscript must be an integer"))
236
237 if rel in subscriptrelations:
238 return subscriptrelations[rel](repo, subset, x, rel, n, order)
239
240 relnames = [r for r in subscriptrelations.keys() if len(r) > 1]
241 raise error.UnknownIdentifier(rel, relnames)
239 242
240 243 def subscriptset(repo, subset, x, y, order):
241 244 raise error.ParseError(_("can't use a subscript in this context"))
@@ -2215,6 +2218,11 methods = {
2215 2218 "parentpost": parentpost,
2216 2219 }
2217 2220
2221 subscriptrelations = {
2222 "g": generationsrel,
2223 "generations": generationsrel,
2224 }
2225
2218 2226 def lookupfn(repo):
2219 2227 return lambda symbol: scmutil.isrevsymbol(repo, symbol)
2220 2228
@@ -649,6 +649,17 parse errors of relation, subscript and
649 649 hg: parse error: relation subscript must be an integer
650 650 [255]
651 651
652 suggested relations
653
654 $ hg debugrevspec '.#generafions[0]'
655 hg: parse error: unknown identifier: generafions
656 (did you mean generations?)
657 [255]
658
659 $ hg debugrevspec '.#f[0]'
660 hg: parse error: unknown identifier: f
661 [255]
662
652 663 parsed tree at stages:
653 664
654 665 $ hg debugrevspec -p all '()'
General Comments 0
You need to be logged in to leave comments. Login now