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