Submitter | Mads Kiilerich |
---|---|
Date | April 13, 2015, 8:26 p.m. |
Message ID | <31a330fcad90837e0c0d.1428956760@localhost.localdomain> |
Download | mbox | patch |
Permalink | /patch/8642/ |
State | Changes Requested |
Headers | show |
Comments
On 4/13/2015 1:26 PM, Mads Kiilerich wrote: > # HG changeset patch > # User Mads Kiilerich <mads@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?
On 04/13/2015 04:26 PM, Mads Kiilerich wrote: > # HG changeset patch > # User Mads Kiilerich <mads@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. I'm curious about what kind of situation creates that. Can you add more details please? Ryan request for tests looks great to me.
Patch
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))