##// END OF EJS Templates
revset: leverage getintrange() helper in relation-subscript operation (API)...
Yuya Nishihara -
r41704:13f7a6a4 default
parent child Browse files
Show More
@@ -43,7 +43,6 b' getstring = revsetlang.getstring'
43 getinteger = revsetlang.getinteger
43 getinteger = revsetlang.getinteger
44 getboolean = revsetlang.getboolean
44 getboolean = revsetlang.getboolean
45 getlist = revsetlang.getlist
45 getlist = revsetlang.getlist
46 getrange = revsetlang.getrange
47 getintrange = revsetlang.getintrange
46 getintrange = revsetlang.getintrange
48 getargs = revsetlang.getargs
47 getargs = revsetlang.getargs
49 getargsdict = revsetlang.getargsdict
48 getargsdict = revsetlang.getargsdict
@@ -256,14 +255,14 b' def _splitrange(a, b):'
256 descdepths = (max(a, 0), b + 1)
255 descdepths = (max(a, 0), b + 1)
257 return ancdepths, descdepths
256 return ancdepths, descdepths
258
257
259 def generationsrel(repo, subset, x, rel, a, b, order):
258 def generationsrel(repo, subset, x, rel, z, order):
260 # TODO: rewrite tests, and drop startdepth argument from ancestors() and
259 # TODO: rewrite tests, and drop startdepth argument from ancestors() and
261 # descendants() predicates
260 # descendants() predicates
262 if a is None:
261 a, b = getintrange(z,
263 a = -(dagop.maxlogdepth - 1)
262 _('relation subscript must be an integer or a range'),
264 if b is None:
263 _('relation subscript bounds must be integers'),
265 b = +(dagop.maxlogdepth - 1)
264 deffirst=-(dagop.maxlogdepth - 1),
266
265 deflast=+(dagop.maxlogdepth - 1))
267 (ancstart, ancstop), (descstart, descstop) = _splitrange(a, b)
266 (ancstart, ancstop), (descstart, descstop) = _splitrange(a, b)
268
267
269 if ancstart is None and descstart is None:
268 if ancstart is None and descstart is None:
@@ -288,21 +287,8 b' def relsubscriptset(repo, subset, x, y, '
288 # experimental so undocumented. see the wiki for further ideas.
287 # experimental so undocumented. see the wiki for further ideas.
289 # https://www.mercurial-scm.org/wiki/RevsetOperatorPlan
288 # https://www.mercurial-scm.org/wiki/RevsetOperatorPlan
290 rel = getsymbol(y)
289 rel = getsymbol(y)
291 try:
292 a, b = getrange(z, '')
293 except error.ParseError:
294 a = getinteger(z, _("relation subscript must be an integer"))
295 b = a
296 else:
297 def getbound(i):
298 if i is None:
299 return None
300 msg = _("relation subscript bounds must be integers")
301 return getinteger(i, msg)
302 a, b = [getbound(i) for i in (a, b)]
303
304 if rel in subscriptrelations:
290 if rel in subscriptrelations:
305 return subscriptrelations[rel](repo, subset, x, rel, a, b, order)
291 return subscriptrelations[rel](repo, subset, x, rel, z, order)
306
292
307 relnames = [r for r in subscriptrelations.keys() if len(r) > 1]
293 relnames = [r for r in subscriptrelations.keys() if len(r) > 1]
308 raise error.UnknownIdentifier(rel, relnames)
294 raise error.UnknownIdentifier(rel, relnames)
@@ -643,10 +643,10 b' parse errors of relation, subscript and '
643 [255]
643 [255]
644
644
645 $ hg debugrevspec '.#generations[a]'
645 $ hg debugrevspec '.#generations[a]'
646 hg: parse error: relation subscript must be an integer
646 hg: parse error: relation subscript must be an integer or a range
647 [255]
647 [255]
648 $ hg debugrevspec '.#generations[1-2]'
648 $ hg debugrevspec '.#generations[1-2]'
649 hg: parse error: relation subscript must be an integer
649 hg: parse error: relation subscript must be an integer or a range
650 [255]
650 [255]
651 $ hg debugrevspec '.#generations[foo:bar]'
651 $ hg debugrevspec '.#generations[foo:bar]'
652 hg: parse error: relation subscript bounds must be integers
652 hg: parse error: relation subscript bounds must be integers
General Comments 0
You need to be logged in to leave comments. Login now