changeset 4390:312b9e8a4c9c

revset: use getintrange() to parse relation subscript After 13f7a6a4f0db parsing the tokens into usable values needs to happen inside subscript relation functions.
author Anton Shestakov <av6@dwimlabs.net>
date Wed, 06 Feb 2019 13:49:29 +0800
parents 88887b2be07c
children 054ff759f2fd
files hgext3rd/topic/revset.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/revset.py	Sun Feb 03 12:04:50 2019 +0100
+++ b/hgext3rd/topic/revset.py	Wed Feb 06 13:49:29 2019 +0800
@@ -108,7 +108,7 @@
     return revset.baseset(stack.stack(repo, branch=branch, topic=topic)[1:]) & subset
 
 if util.safehasattr(revset, 'subscriptrelations'):
-    def stackrel(repo, subset, x, rel, a, *args):
+    def stackrel(repo, subset, x, rel, z, order):
         """This is a revset-flavored implementation of stack aliases.
 
         The syntax is: rev#stack[n] or rev#s[n]. Plenty of logic is borrowed
@@ -116,11 +116,15 @@
         (e.g. when stack index is too high), this returns empty set to be more
         revset-friendly.
         """
-        # hg 4.9 provides one bound, hg 5.0 provides two
-        if len(args) == 2:
-            b = args[0]
+        # hg 4.9 provides a number or None, hg 5.0 provides a tuple of tokens
+        if isinstance(z, tuple):
+            a, b = revset.getintrange(
+                z,
+                'relation subscript must be an integer or a range',
+                'relation subscript bounds must be integers',
+                None, None)
         else:
-            b = a
+            a = b = z
 
         s = revset.getset(repo, revset.fullreposet(repo), x)
         if not s: