Patchwork [3,of,5] revsetlang: unnest "if True" in formatrevspec()

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 7, 2018, 6:31 a.m.
Message ID <11003d3f4751eb00f04c.1515306713@mimosa>
Download mbox | patch
Permalink /patch/26596/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 7, 2018, 6:31 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1491033407 -32400
#      Sat Apr 01 16:56:47 2017 +0900
# Node ID 11003d3f4751eb00f04c43bbeed25fe044a3db87
# Parent  cac1c609a310d403b4d1acefac35aa86d871b608
revsetlang: unnest "if True" in formatrevspec()

Patch

diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -630,22 +630,20 @@  def formatspec(expr, *args):
             break
         ret.append(expr[pos:q])
         pos = q + 1
-        if True:
+        d = expr[pos]
+        if d == '%':
+            ret.append(d)
+        elif d in 'dsnbr':
+            ret.append(argtype(d, args[arg]))
+            arg += 1
+        elif d == 'l':
+            # a list of some type
+            pos += 1
             d = expr[pos]
-            if d == '%':
-                ret.append(d)
-            elif d in 'dsnbr':
-                ret.append(argtype(d, args[arg]))
-                arg += 1
-            elif d == 'l':
-                # a list of some type
-                pos += 1
-                d = expr[pos]
-                ret.append(listexp(list(args[arg]), d))
-                arg += 1
-            else:
-                raise error.Abort(_('unexpected revspec format character %s')
-                                  % d)
+            ret.append(listexp(list(args[arg]), d))
+            arg += 1
+        else:
+            raise error.Abort(_('unexpected revspec format character %s') % d)
         pos += 1
 
     return ''.join(ret)