[PATCH 3 of 4] py3: use bytestr wrapper in revsetlang.formatspec()

Yuya Nishihara yuya at tcha.org
Thu Mar 16 11:31:12 EDT 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1489667605 -32400
#      Thu Mar 16 21:33:25 2017 +0900
# Node ID 649866574c86bae35ab8143c50af72bee7fef810
# Parent  aae1bd4b8a03ffe6cb47c23da55b2f70ff5607ef
py3: use bytestr wrapper in revsetlang.formatspec()

This backs out 1c48a8278b2f and wraps expr by bytestr() instead.

diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -640,14 +640,15 @@ def formatspec(expr, *args):
         m = l // 2
         return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t))
 
+    expr = pycompat.bytestr(expr)
     ret = ''
     pos = 0
     arg = 0
     while pos < len(expr):
-        c = expr[pos:pos + 1]
+        c = expr[pos]
         if c == '%':
             pos += 1
-            d = expr[pos:pos + 1]
+            d = expr[pos]
             if d == '%':
                 ret += d
             elif d in 'dsnbr':
@@ -656,7 +657,7 @@ def formatspec(expr, *args):
             elif d == 'l':
                 # a list of some type
                 pos += 1
-                d = expr[pos:pos + 1]
+                d = expr[pos]
                 ret += listexp(list(args[arg]), d)
                 arg += 1
             else:


More information about the Mercurial-devel mailing list