[PATCH 2 of 3 various] context: make sure __str__ works, also when there is no _changectx
Ryan McElroy
rm at fb.com
Tue Apr 14 03:49:13 UTC 2015
On 4/13/2015 1:26 PM, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <mads at kiilerich.com>
> # Date 1426800170 -3600
> # Thu Mar 19 22:22:50 2015 +0100
> # Node ID 31a330fcad90837e0c0d858db69e67a7f74ec997
> # Parent dec70e4b55cad0d4f1ef1ed0468e2710cb4d49db
> context: make sure __str__ works, also when there is no _changectx
>
> Before, it could crash when trying to print the wrong kind of object at the
> wrong time.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -652,7 +652,10 @@ class basefilectx(object):
> return False
>
> def __str__(self):
> - return "%s@%s" % (self.path(), self._changectx)
> + try:
> + return "%s@%s" % (self.path(), self._changectx)
> + except error.LookupError:
> + return "%s@???" % self.path()
>
> def __repr__(self):
> return "<%s %s>" % (type(self).__name__, str(self))
Can you add a test that demonstrates the issue?
More information about the Mercurial-devel
mailing list