context: make sure __str__ works, also when there is no _changectx
authorMads Kiilerich <mads@kiilerich.com>
Thu, 19 Mar 2015 22:22:50 +0100
changeset 30270 e25ce44f8447
parent 30269 d71db0e3b7b9
child 30271 0fa1a41d04e4
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.
mercurial/context.py
--- a/mercurial/context.py	Tue Oct 18 16:45:39 2016 +0200
+++ b/mercurial/context.py	Thu Mar 19 22:22:50 2015 +0100
@@ -709,7 +709,10 @@
             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))