##// END OF EJS Templates
revset: add experimental ancestors/descendants relation subscript...
Yuya Nishihara -
r33417:d1b13d49 default
parent child Browse files
Show More
@@ -155,7 +155,23 b' def relationset(repo, subset, x, y, orde'
155 raise error.ParseError(_("can't use a relation in this context"))
155 raise error.ParseError(_("can't use a relation in this context"))
156
156
157 def relsubscriptset(repo, subset, x, y, z, order):
157 def relsubscriptset(repo, subset, x, y, z, order):
158 raise error.ParseError(_("can't use a relation in this context"))
158 # this is pretty basic implementation of 'x#y[z]' operator, still
159 # experimental so undocumented. see the wiki for further ideas.
160 # https://www.mercurial-scm.org/wiki/RevsetOperatorPlan
161 rel = getsymbol(y)
162 n = getinteger(z, _("relation subscript must be an integer"))
163
164 # TODO: perhaps this should be a table of relation functions
165 if rel in ('g', 'generations'):
166 # TODO: support range, rewrite tests, and drop startdepth argument
167 # from ancestors() and descendants() predicates
168 if n <= 0:
169 n = -n
170 return _ancestors(repo, subset, x, startdepth=n, stopdepth=n + 1)
171 else:
172 return _descendants(repo, subset, x, startdepth=n, stopdepth=n + 1)
173
174 raise error.UnknownIdentifier(rel, ['generations'])
159
175
160 def subscriptset(repo, subset, x, y, order):
176 def subscriptset(repo, subset, x, y, order):
161 raise error.ParseError(_("can't use a subscript in this context"))
177 raise error.ParseError(_("can't use a subscript in this context"))
@@ -512,8 +512,12 b' relation-subscript operator has the high'
512 ('symbol', 'generations')
512 ('symbol', 'generations')
513 (negate
513 (negate
514 ('symbol', '1'))))
514 ('symbol', '1'))))
515 hg: parse error: can't use a relation in this context
515 9
516 [255]
516 8
517 7
518 6
519 5
520 4
517
521
518 $ hg debugrevspec -p parsed --no-show-revs 'not public()#generations[0]'
522 $ hg debugrevspec -p parsed --no-show-revs 'not public()#generations[0]'
519 * parsed:
523 * parsed:
@@ -524,8 +528,6 b' relation-subscript operator has the high'
524 None)
528 None)
525 ('symbol', 'generations')
529 ('symbol', 'generations')
526 ('symbol', '0')))
530 ('symbol', '0')))
527 hg: parse error: can't use a relation in this context
528 [255]
529
531
530 left-hand side of relation-subscript operator should be optimized recursively:
532 left-hand side of relation-subscript operator should be optimized recursively:
531
533
@@ -551,8 +553,6 b' left-hand side of relation-subscript ope'
551 ('symbol', 'generations')
553 ('symbol', 'generations')
552 ('symbol', '0')
554 ('symbol', '0')
553 define)
555 define)
554 hg: parse error: can't use a relation in this context
555 [255]
556
556
557 resolution of subscript and relation-subscript ternary operators:
557 resolution of subscript and relation-subscript ternary operators:
558
558
@@ -572,7 +572,7 b' resolution of subscript and relation-sub'
572 ('symbol', 'rel')
572 ('symbol', 'rel')
573 ('symbol', '0')
573 ('symbol', '0')
574 define)
574 define)
575 hg: parse error: can't use a relation in this context
575 hg: parse error: unknown identifier: rel
576 [255]
576 [255]
577
577
578 $ hg debugrevspec -p analyzed '(tip#rel)[0]'
578 $ hg debugrevspec -p analyzed '(tip#rel)[0]'
@@ -610,7 +610,7 b' resolution of subscript and relation-sub'
610 ('symbol', 'rel1')
610 ('symbol', 'rel1')
611 ('symbol', '1')
611 ('symbol', '1')
612 define)
612 define)
613 hg: parse error: can't use a relation in this context
613 hg: parse error: unknown identifier: rel1
614 [255]
614 [255]
615
615
616 $ hg debugrevspec -p analyzed 'tip#rel0[0]#rel1[1]'
616 $ hg debugrevspec -p analyzed 'tip#rel0[0]#rel1[1]'
@@ -624,7 +624,7 b' resolution of subscript and relation-sub'
624 ('symbol', 'rel1')
624 ('symbol', 'rel1')
625 ('symbol', '1')
625 ('symbol', '1')
626 define)
626 define)
627 hg: parse error: can't use a relation in this context
627 hg: parse error: unknown identifier: rel1
628 [255]
628 [255]
629
629
630 parse errors of relation, subscript and relation-subscript operators:
630 parse errors of relation, subscript and relation-subscript operators:
@@ -645,6 +645,13 b' parse errors of relation, subscript and '
645 hg: parse error at 1: invalid token
645 hg: parse error at 1: invalid token
646 [255]
646 [255]
647
647
648 $ hg debugrevspec '.#generations[a]'
649 hg: parse error: relation subscript must be an integer
650 [255]
651 $ hg debugrevspec '.#generations[1-2]'
652 hg: parse error: relation subscript must be an integer
653 [255]
654
648 parsed tree at stages:
655 parsed tree at stages:
649
656
650 $ hg debugrevspec -p all '()'
657 $ hg debugrevspec -p all '()'
@@ -1180,6 +1187,27 b' test descendants with depth limit'
1180 5
1187 5
1181 7
1188 7
1182
1189
1190 test ancestors/descendants relation subscript:
1191
1192 $ log 'tip#generations[0]'
1193 9
1194 $ log '.#generations[-1]'
1195 8
1196 $ log '.#g[(-1)]'
1197 8
1198
1199 $ hg debugrevspec -p parsed 'roots(:)#g[2]'
1200 * parsed:
1201 (relsubscript
1202 (func
1203 ('symbol', 'roots')
1204 (rangeall
1205 None))
1206 ('symbol', 'g')
1207 ('symbol', '2'))
1208 2
1209 3
1210
1183 test author
1211 test author
1184
1212
1185 $ log 'author(bob)'
1213 $ log 'author(bob)'
General Comments 0
You need to be logged in to leave comments. Login now