Patchwork [STABLE] py3: fix formatting of LookupError for workingctx

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 13, 2020, 8:29 a.m.
Message ID <63842da54dde663b9227.1599985771@mimosa>
Download mbox | patch
Permalink /patch/47148/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 13, 2020, 8:29 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1599980363 -32400
#      Sun Sep 13 15:59:23 2020 +0900
# Branch stable
# Node ID 63842da54dde663b9227ca4c5e7615649073303c
# Parent  d4a83a7d132ace8e3cfe366d9ef56fb99f26ffab
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.
Pulkit Goyal - Sept. 14, 2020, 7:15 a.m.
On Sun, Sep 13, 2020 at 2:02 PM Yuya Nishihara <yuya@tcha.org> wrote:
>
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1599980363 -32400
> #      Sun Sep 13 15:59:23 2020 +0900
> # Branch stable
> # Node ID 63842da54dde663b9227ca4c5e7615649073303c
> # Parent  d4a83a7d132ace8e3cfe366d9ef56fb99f26ffab
> 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.

Queued for stable, many thanks!

Patch

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -73,7 +73,10 @@  class LookupError(RevlogError, KeyError)
             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)