comparison mercurial/context.py @ 19582:bda1d48bb07f

basefilectx: move __eq__ from filectx We also add type checking for extra protection.
author Sean Farley <sean.michael.farley@gmail.com>
date Sun, 11 Aug 2013 22:49:03 -0500
parents fe50d21be01a
children e5074d82afc9
comparison
equal deleted inserted replaced
19581:fe50d21be01a 19582:bda1d48bb07f
465 try: 465 try:
466 return hash((self._path, self._filenode)) 466 return hash((self._path, self._filenode))
467 except AttributeError: 467 except AttributeError:
468 return id(self) 468 return id(self)
469 469
470 def __eq__(self, other):
471 try:
472 return (type(self) == type(other) and self._path == other._path
473 and self._filenode == other._filenode)
474 except AttributeError:
475 return False
476
470 class filectx(basefilectx): 477 class filectx(basefilectx):
471 """A filecontext object makes access to data related to a particular 478 """A filecontext object makes access to data related to a particular
472 filerevision convenient.""" 479 filerevision convenient."""
473 def __init__(self, repo, path, changeid=None, fileid=None, 480 def __init__(self, repo, path, changeid=None, fileid=None,
474 filelog=None, changectx=None): 481 filelog=None, changectx=None):
513 # 520 #
514 # Linkrevs have several serious troubles with filtering that are 521 # Linkrevs have several serious troubles with filtering that are
515 # complicated to solve. Proper handling of the issue here should be 522 # complicated to solve. Proper handling of the issue here should be
516 # considered when solving linkrev issue are on the table. 523 # considered when solving linkrev issue are on the table.
517 return changectx(self._repo.unfiltered(), self._changeid) 524 return changectx(self._repo.unfiltered(), self._changeid)
518
519 def __eq__(self, other):
520 try:
521 return (self._path == other._path
522 and self._filenode == other._filenode)
523 except AttributeError:
524 return False
525 525
526 def __ne__(self, other): 526 def __ne__(self, other):
527 return not (self == other) 527 return not (self == other)
528 528
529 def filectx(self, fileid): 529 def filectx(self, fileid):