util: teach escapedata() about bytearray
re.map doesn't seem to know about bytearray (at least in Python 2).
Cast bytearray to a bytes to work around this inconvenience.
Differential Revision: https://phab.mercurial-scm.org/D2582
--- a/mercurial/util.py Fri Mar 02 22:59:12 2018 -0500
+++ b/mercurial/util.py Fri Mar 02 22:47:18 2018 -0500
@@ -702,6 +702,9 @@
DATA_ESCAPE_RE = remod.compile(br'[\x00-\x08\x0a-\x1f\\\x7f-\xff]')
def escapedata(s):
+ if isinstance(s, bytearray):
+ s = bytes(s)
+
return DATA_ESCAPE_RE.sub(lambda m: DATA_ESCAPE_MAP[m.group(0)], s)
class fileobjectobserver(object):