# HG changeset patch # User Augie Fackler # Date 1560792101 14400 # Node ID 7a9e038d38a2fd59a5043e498205778ddb001788 # Parent ed9a995640518fd7fa893817f0250f4d319a4b40# Parent b6387a65851d4421d5580b1a4db4c55366a94ec8 merge with stable diff -r ed9a99564051 -r 7a9e038d38a2 mercurial/utils/cborutil.py --- a/mercurial/utils/cborutil.py Fri Jun 14 00:30:33 2019 -0400 +++ b/mercurial/utils/cborutil.py Mon Jun 17 13:21:41 2019 -0400 @@ -214,6 +214,14 @@ fn = STREAM_ENCODERS.get(v.__class__) if not fn: + # handle subtypes such as encoding.localstr and util.sortdict + for ty in STREAM_ENCODERS: + if not isinstance(v, ty): + continue + fn = STREAM_ENCODERS[ty] + break + + if not fn: raise ValueError('do not know how to encode %s' % type(v)) return fn(v) diff -r ed9a99564051 -r 7a9e038d38a2 tests/test-template-functions.t --- a/tests/test-template-functions.t Fri Jun 14 00:30:33 2019 -0400 +++ b/tests/test-template-functions.t Mon Jun 17 13:21:41 2019 -0400 @@ -1562,6 +1562,20 @@ $ HGENCODING=ascii hg log -T "{'`cat latin1`'|json}\n" -l1 "\udce9" +cbor filter is bytes transparent, which should handle bytes subtypes +as bytes: + + $ HGENCODING=ascii hg log -T "{branch|cbor}" -r0 \ + > | "$PYTHON" "$TESTTMP/decodecbor.py" + [ + '?' + ] + $ HGENCODING=latin-1 hg log -T "{branch|cbor}" -r0 \ + > | "$PYTHON" "$TESTTMP/decodecbor.py" + [ + '\xe9' + ] + utf8 filter: $ HGENCODING=ascii hg log -T "round-trip: {branch|utf8|hex}\n" -r0