[PATCH 2 of 4 py3] revsetlang: work around repr() returning unicode on py3
Augie Fackler
raf at durin42.com
Tue Mar 21 15:13:01 EDT 2017
# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1489900459 14400
# Sun Mar 19 01:14:19 2017 -0400
# Node ID 63466a54ec9e266031cce12fbd699ccfccd40738
# Parent a4745fd9219ed5b408bfc0403a4a8e6acd41df6c
revsetlang: work around repr() returning unicode on py3
I'm not confident in my choice of "encode to utf8" here: it seems
reasonable that we could expect the revset engine to do the right
thing there. On the other hand these strings might have encoding
weirdness to begin with if there's `branch(some-weird-byte-sequence)`.
diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -607,7 +607,11 @@ def formatspec(expr, *args):
'''
def quote(s):
- return repr(str(s))
+ r = repr(bytes(s))
+ if pycompat.ispy3:
+ r = r[1:] # strip off b prefix
+ return r.encode('utf-8')
+ return r
def argtype(c, arg):
if c == 'd':
More information about the Mercurial-devel
mailing list