revlog: fix error about unknown compression format in py3
authorValentin Gatien-Baron <vgatien-baron@janestreet.com>
Tue, 06 Apr 2021 13:49:19 -0400
changeset 46852 fbfb1d6d8459
parent 46851 3aa78f2aea48
child 46853 eed3e2b79b48
revlog: fix error about unknown compression format in py3 In py2, the error is something like: abort: unknown compression type 'x'! In py3, we get the following unhelpful message: abort: unknown compression type <memory at 0x7f4650b5cdc8>! Switch to something like: abort: unknown compression type 78! Differential Revision: https://phab.mercurial-scm.org/D10318
mercurial/revlog.py
--- a/mercurial/revlog.py	Wed Apr 07 12:15:28 2021 +0200
+++ b/mercurial/revlog.py	Tue Apr 06 13:49:19 2021 -0400
@@ -13,6 +13,7 @@
 
 from __future__ import absolute_import
 
+import binascii
 import collections
 import contextlib
 import errno
@@ -2296,7 +2297,9 @@
                 compressor = engine.revlogcompressor(self._compengineopts)
                 self._decompressors[t] = compressor
             except KeyError:
-                raise error.RevlogError(_(b'unknown compression type %r') % t)
+                raise error.RevlogError(
+                    _(b'unknown compression type %s') % binascii.hexlify(t)
+                )
 
         return compressor.decompress(data)