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

login
register
mail settings
Submitter Yuya Nishihara
Date March 16, 2017, 3:31 p.m.
Message ID <649866574c86bae35ab8.1489678272@mimosa>
Download mbox | patch
Permalink /patch/19393/
State Accepted
Headers show

Comments

Yuya Nishihara - March 16, 2017, 3:31 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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: