comparison mercurial/context.py @ 19581:fe50d21be01a

basefilectx: move __hash__ from filectx
author Sean Farley <sean.michael.farley@gmail.com>
date Sun, 11 Aug 2013 22:47:39 -0500
parents e86a594ab11f
children bda1d48bb07f
comparison
equal deleted inserted replaced
19580:e86a594ab11f 19581:fe50d21be01a
459 return "%s@%s" % (self.path(), short(self.node())) 459 return "%s@%s" % (self.path(), short(self.node()))
460 460
461 def __repr__(self): 461 def __repr__(self):
462 return "<%s %s>" % (type(self).__name__, str(self)) 462 return "<%s %s>" % (type(self).__name__, str(self))
463 463
464 def __hash__(self):
465 try:
466 return hash((self._path, self._filenode))
467 except AttributeError:
468 return id(self)
469
464 class filectx(basefilectx): 470 class filectx(basefilectx):
465 """A filecontext object makes access to data related to a particular 471 """A filecontext object makes access to data related to a particular
466 filerevision convenient.""" 472 filerevision convenient."""
467 def __init__(self, repo, path, changeid=None, fileid=None, 473 def __init__(self, repo, path, changeid=None, fileid=None,
468 filelog=None, changectx=None): 474 filelog=None, changectx=None):
507 # 513 #
508 # Linkrevs have several serious troubles with filtering that are 514 # Linkrevs have several serious troubles with filtering that are
509 # complicated to solve. Proper handling of the issue here should be 515 # complicated to solve. Proper handling of the issue here should be
510 # considered when solving linkrev issue are on the table. 516 # considered when solving linkrev issue are on the table.
511 return changectx(self._repo.unfiltered(), self._changeid) 517 return changectx(self._repo.unfiltered(), self._changeid)
512
513 def __hash__(self):
514 try:
515 return hash((self._path, self._filenode))
516 except AttributeError:
517 return id(self)
518 518
519 def __eq__(self, other): 519 def __eq__(self, other):
520 try: 520 try:
521 return (self._path == other._path 521 return (self._path == other._path
522 and self._filenode == other._filenode) 522 and self._filenode == other._filenode)