##// 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 43 getinteger = revsetlang.getinteger
44 44 getboolean = revsetlang.getboolean
45 45 getlist = revsetlang.getlist
46 getrange = revsetlang.getrange
47 46 getintrange = revsetlang.getintrange
48 47 getargs = revsetlang.getargs
49 48 getargsdict = revsetlang.getargsdict
@@ -256,14 +255,14 b' def _splitrange(a, b):'
256 255 descdepths = (max(a, 0), b + 1)
257 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 259 # TODO: rewrite tests, and drop startdepth argument from ancestors() and
261 260 # descendants() predicates
262 if a is None:
263 a = -(dagop.maxlogdepth - 1)
264 if b is None:
265 b = +(dagop.maxlogdepth - 1)
266
261 a, b = getintrange(z,
262 _('relation subscript must be an integer or a range'),
263 _('relation subscript bounds must be integers'),
264 deffirst=-(dagop.maxlogdepth - 1),
265 deflast=+(dagop.maxlogdepth - 1))
267 266 (ancstart, ancstop), (descstart, descstop) = _splitrange(a, b)
268 267
269 268 if ancstart is None and descstart is None:
@@ -288,21 +287,8 b' def relsubscriptset(repo, subset, x, y, '
288 287 # experimental so undocumented. see the wiki for further ideas.
289 288 # https://www.mercurial-scm.org/wiki/RevsetOperatorPlan
290 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 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 293 relnames = [r for r in subscriptrelations.keys() if len(r) > 1]
308 294 raise error.UnknownIdentifier(rel, relnames)
@@ -643,10 +643,10 b' parse errors of relation, subscript and '
643 643 [255]
644 644
645 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 647 [255]
648 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 650 [255]
651 651 $ hg debugrevspec '.#generations[foo:bar]'
652 652 hg: parse error: relation subscript bounds must be integers
General Comments 0
You need to be logged in to leave comments. Login now