changeset 35560:3a8810c1b9bc

revsetlang: use iterator to track current argument in formatspec()
author Yuya Nishihara <yuya@tcha.org>
date Sat, 01 Apr 2017 17:04:49 +0900
parents a480551bd1b4
children 4c3a4bb31c0e
files mercurial/revsetlang.py
diffstat 1 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revsetlang.py	Sat Apr 01 16:56:47 2017 +0900
+++ b/mercurial/revsetlang.py	Sat Apr 01 17:04:49 2017 +0900
@@ -620,9 +620,9 @@
         return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t))
 
     expr = pycompat.bytestr(expr)
+    argiter = iter(args)
     ret = []
     pos = 0
-    arg = 0
     while pos < len(expr):
         q = expr.find('%', pos)
         if q < 0:
@@ -634,14 +634,12 @@
         if d == '%':
             ret.append(d)
         elif d in 'dsnbr':
-            ret.append(argtype(d, args[arg]))
-            arg += 1
+            ret.append(argtype(d, next(argiter)))
         elif d == 'l':
             # a list of some type
             pos += 1
             d = expr[pos]
-            ret.append(listexp(list(args[arg]), d))
-            arg += 1
+            ret.append(listexp(list(next(argiter)), d))
         else:
             raise error.Abort(_('unexpected revspec format character %s') % d)
         pos += 1