# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1599980363 -32400
#      Sun Sep 13 15:59:23 2020 +0900
# Branch stable
# Node ID bd5b2b29b82df1e2de214a59a8aa60eb80ee27f9
# Parent  4ebc5f325bedfc8fc98b3c41fda7892563142146
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.

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