##// END OF EJS Templates
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore -
r6469:fb502719 default
parent child Browse files
Show More
@@ -1047,6 +1047,9 b' def grep(ui, repo, pattern, *pats, **opt'
1047 self.colstart = colstart
1047 self.colstart = colstart
1048 self.colend = colend
1048 self.colend = colend
1049
1049
1050 def __hash__(self):
1051 return hash((self.linenum, self.line))
1052
1050 def __eq__(self, other):
1053 def __eq__(self, other):
1051 return self.line == other.line
1054 return self.line == other.line
1052
1055
@@ -34,6 +34,12 b' class changectx(object):'
34 def __repr__(self):
34 def __repr__(self):
35 return "<changectx %s>" % str(self)
35 return "<changectx %s>" % str(self)
36
36
37 def __hash__(self):
38 try:
39 return hash(self._rev)
40 except AttributeError:
41 return id(self)
42
37 def __eq__(self, other):
43 def __eq__(self, other):
38 try:
44 try:
39 return self._rev == other._rev
45 return self._rev == other._rev
@@ -210,6 +216,12 b' class filectx(object):'
210 def __repr__(self):
216 def __repr__(self):
211 return "<filectx %s>" % str(self)
217 return "<filectx %s>" % str(self)
212
218
219 def __hash__(self):
220 try:
221 return hash((self._path, self._fileid))
222 except AttributeError:
223 return id(self)
224
213 def __eq__(self, other):
225 def __eq__(self, other):
214 try:
226 try:
215 return (self._path == other._path
227 return (self._path == other._path
General Comments 0
You need to be logged in to leave comments. Login now