D5426: error: implement __str__ on RevlogError to fix some output defects on Py3
durin42 (Augie Fackler)
phabricator at mercurial-scm.org
Fri Dec 14 17:14:47 UTC 2018
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
We open-code encoding.unimethod here to avoid cycles, and do a local
import of encoding when someone str()s a RevlogError. It's not my
favorite solution, but it gets the job done.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D5426
AFFECTED FILES
mercurial/error.py
CHANGE DETAILS
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -44,6 +44,14 @@
class RevlogError(StorageError):
__bytes__ = _tobytes
+ def __str__(self):
+ # avoid cycle, and directly implement unimethod for this
+ # __str__ to allow delaying the import of encoding until
+ # someone actually wants the __str__ of a RevlogError (which
+ # should be very rare).
+ from . import encoding
+ return encoding.unifromlocal(_tobytes(self))
+
class FilteredIndexError(IndexError):
__bytes__ = _tobytes
To: durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list