py3: fix formatting of LookupError for workingctx stable
authorYuya Nishihara <yuya@tcha.org>
Sun, 13 Sep 2020 15:59:23 +0900
branchstable
changeset 45503 bd5b2b29b82d
parent 45416 4ebc5f325bed
child 45505 e3df1f560d9a
child 45508 27822b8436bf
py3: fix formatting of LookupError for workingctx Spotted while writing broken tests for "hg grep -fr'wdir()'". basectx._fileinfo() raises ManifestLookupError(self._node, ..), but _node of the workingctx is None for historical reasons.
mercurial/error.py
--- a/mercurial/error.py	Fri Sep 11 14:41:05 2020 +0900
+++ b/mercurial/error.py	Sun Sep 13 15:59:23 2020 +0900
@@ -73,7 +73,10 @@
             from .node import short
 
             name = short(name)
-        RevlogError.__init__(self, b'%s@%s: %s' % (index, name, message))
+        # if name is a binary node, it can be None
+        RevlogError.__init__(
+            self, b'%s@%s: %s' % (index, pycompat.bytestr(name), message)
+        )
 
     def __bytes__(self):
         return RevlogError.__bytes__(self)