comparison mercurial/context.py @ 19546:a45cf68dd9a2

basectx: move __repr__ from changectx We change the hardcoded 'changectx' to instead use type(self).__name__ so that objects that inherit from basectx in the future will be able to use the same representation.
author Sean Farley <sean.michael.farley@gmail.com>
date Fri, 02 Aug 2013 18:24:08 -0500
parents 5af7045b0b18
children 0537c0cfd87c
comparison
equal deleted inserted replaced
19545:5af7045b0b18 19546:a45cf68dd9a2
38 def __str__(self): 38 def __str__(self):
39 return short(self.node()) 39 return short(self.node())
40 40
41 def __int__(self): 41 def __int__(self):
42 return self.rev() 42 return self.rev()
43
44 def __repr__(self):
45 return "<%s %s>" % (type(self).__name__, str(self))
43 46
44 def rev(self): 47 def rev(self):
45 return self._rev 48 return self._rev
46 def node(self): 49 def node(self):
47 return self._node 50 return self._node
150 changeid = hex(changeid) 153 changeid = hex(changeid)
151 except TypeError: 154 except TypeError:
152 pass 155 pass
153 raise error.RepoLookupError( 156 raise error.RepoLookupError(
154 _("unknown revision '%s'") % changeid) 157 _("unknown revision '%s'") % changeid)
155
156 def __repr__(self):
157 return "<changectx %s>" % str(self)
158 158
159 def __hash__(self): 159 def __hash__(self):
160 try: 160 try:
161 return hash(self._rev) 161 return hash(self._rev)
162 except AttributeError: 162 except AttributeError: