Patchwork D10318: revlog: fix error about unknown compression format in py3

login
register
mail settings
Submitter phabricator
Date April 6, 2021, 5:53 p.m.
Message ID <differential-rev-PHID-DREV-qnssdjk4u6dy6lwijbf2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48635/
State Superseded
Headers show

Comments

phabricator - April 6, 2021, 5:53 p.m.
valentin.gatienbaron created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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!

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10318

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




To: valentin.gatienbaron, indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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)