Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/context.py @ 19580:e86a594ab11f
basefilectx: move __repr__ from filectx
We change the hardcoded 'filectx' to instead use type(self).__name__ so that objects that
inherit from basefilectx in the future will be able to use the same representation.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Sun, 11 Aug 2013 22:46:54 -0500 |
parents | 964844d64ef8 |
children | fe50d21be01a |
comparison
equal
deleted
inserted
replaced
19579:964844d64ef8 | 19580:e86a594ab11f |
---|---|
456 return False | 456 return False |
457 | 457 |
458 def __str__(self): | 458 def __str__(self): |
459 return "%s@%s" % (self.path(), short(self.node())) | 459 return "%s@%s" % (self.path(), short(self.node())) |
460 | 460 |
461 def __repr__(self): | |
462 return "<%s %s>" % (type(self).__name__, str(self)) | |
463 | |
461 class filectx(basefilectx): | 464 class filectx(basefilectx): |
462 """A filecontext object makes access to data related to a particular | 465 """A filecontext object makes access to data related to a particular |
463 filerevision convenient.""" | 466 filerevision convenient.""" |
464 def __init__(self, repo, path, changeid=None, fileid=None, | 467 def __init__(self, repo, path, changeid=None, fileid=None, |
465 filelog=None, changectx=None): | 468 filelog=None, changectx=None): |
504 # | 507 # |
505 # Linkrevs have several serious troubles with filtering that are | 508 # Linkrevs have several serious troubles with filtering that are |
506 # complicated to solve. Proper handling of the issue here should be | 509 # complicated to solve. Proper handling of the issue here should be |
507 # considered when solving linkrev issue are on the table. | 510 # considered when solving linkrev issue are on the table. |
508 return changectx(self._repo.unfiltered(), self._changeid) | 511 return changectx(self._repo.unfiltered(), self._changeid) |
509 | |
510 def __repr__(self): | |
511 return "<filectx %s>" % str(self) | |
512 | 512 |
513 def __hash__(self): | 513 def __hash__(self): |
514 try: | 514 try: |
515 return hash((self._path, self._filenode)) | 515 return hash((self._path, self._filenode)) |
516 except AttributeError: | 516 except AttributeError: |