diff --git a/mercurial/formatter.py b/mercurial/formatter.py --- a/mercurial/formatter.py +++ b/mercurial/formatter.py @@ -248,15 +248,20 @@ class _plainconverter(object): @staticmethod def formatdict(data, key, value, fmt, sep): '''stringify key-value pairs separated by sep''' + prefmt = pycompat.identity if fmt is None: fmt = '%s=%s' - return sep.join(fmt % (k, v) for k, v in _iteritems(data)) + prefmt = pycompat.bytestr + return sep.join(fmt % (prefmt(k), prefmt(v)) + for k, v in _iteritems(data)) @staticmethod def formatlist(data, name, fmt, sep): '''stringify iterable separated by sep''' + prefmt = pycompat.identity if fmt is None: fmt = '%s' - return sep.join(fmt % e for e in data) + prefmt = pycompat.bytestr + return sep.join(fmt % prefmt(e) for e in data) class plainformatter(baseformatter): '''the default text output scheme''' diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -99,16 +99,20 @@ class _mappable(object): def hybriddict(data, key='key', value='value', fmt=None, gen=None): """Wrap data to support both dict-like and string-like operations""" + prefmt = pycompat.identity if fmt is None: fmt = '%s=%s' + prefmt = pycompat.bytestr return _hybrid(gen, data, lambda k: {key: k, value: data[k]}, - lambda k: fmt % (k, data[k])) + lambda k: fmt % (prefmt(k), prefmt(data[k]))) def hybridlist(data, name, fmt=None, gen=None): """Wrap data to support both list-like and string-like operations""" + prefmt = pycompat.identity if fmt is None: fmt = '%s' - return _hybrid(gen, data, lambda x: {name: x}, lambda x: fmt % x) + prefmt = pycompat.bytestr + return _hybrid(gen, data, lambda x: {name: x}, lambda x: fmt % prefmt(x)) def unwraphybrid(thing): """Return an object which can be stringified possibly by using a legacy