[PATCH 2 of 2] context: make sure __str__ works, also when there is no _changectx
Mads Kiilerich
mads at kiilerich.com
Wed Nov 2 11:25:27 EDT 2016
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1426800170 -3600
# Thu Mar 19 22:22:50 2015 +0100
# Node ID 4b06a40809d781e9aba54718ec2fe1a232d81956
# Parent 90300200bc1fcaedcc6ab109574d08b01ece2853
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
@@ -709,7 +709,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))
More information about the Mercurial-devel
mailing list