Commit cc326951 authored by Paul Moore's avatar Paul Moore
Browse files

python 2.6 compatibility: add __hash__ to classes that have __eq__

parent af2edc9c5bb9
......@@ -1047,6 +1047,9 @@ def grep(ui, repo, pattern, *pats, **opts):
self.colstart = colstart
self.colend = colend
def __hash__(self):
return hash((self.linenum, self.line))
def __eq__(self, other):
return self.line == other.line
......
......@@ -34,6 +34,12 @@ class changectx(object):
def __repr__(self):
return "<changectx %s>" % str(self)
def __hash__(self):
try:
return hash(self._rev)
except AttributeError:
return id(self)
def __eq__(self, other):
try:
return self._rev == other._rev
......@@ -210,6 +216,12 @@ class filectx(object):
def __repr__(self):
return "<filectx %s>" % str(self)
def __hash__(self):
try:
return hash((self._path, self._fileid))
except AttributeError:
return id(self)
def __eq__(self, other):
try:
return (self._path == other._path
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment