Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/context.py @ 3715:6cb3aca69cdc
Make context __eq__ handle arbitrary RHS values
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Mon, 27 Nov 2006 15:27:09 -0800 |
parents | 1bd70d40ec57 |
children | 676b75547d13 |
comparison
equal
deleted
inserted
replaced
3714:198173f3957c | 3715:6cb3aca69cdc |
---|---|
34 | 34 |
35 def __repr__(self): | 35 def __repr__(self): |
36 return "<changectx %s>" % str(self) | 36 return "<changectx %s>" % str(self) |
37 | 37 |
38 def __eq__(self, other): | 38 def __eq__(self, other): |
39 return self._rev == other._rev | 39 try: |
40 return self._rev == other._rev | |
41 except AttributeError: | |
42 return False | |
40 | 43 |
41 def __nonzero__(self): | 44 def __nonzero__(self): |
42 return self._rev != nullrev | 45 return self._rev != nullrev |
43 | 46 |
44 def __getattr__(self, name): | 47 def __getattr__(self, name): |
174 | 177 |
175 def __repr__(self): | 178 def __repr__(self): |
176 return "<filectx %s>" % str(self) | 179 return "<filectx %s>" % str(self) |
177 | 180 |
178 def __eq__(self, other): | 181 def __eq__(self, other): |
179 return self._path == other._path and self._changeid == other._changeid | 182 try: |
183 return (self._path == other._path | |
184 and self._changeid == other._changeid) | |
185 except AttributeError: | |
186 return False | |
180 | 187 |
181 def filectx(self, fileid): | 188 def filectx(self, fileid): |
182 '''opens an arbitrary revision of the file without | 189 '''opens an arbitrary revision of the file without |
183 opening a new filelog''' | 190 opening a new filelog''' |
184 return filectx(self._repo, self._path, fileid=fileid, | 191 return filectx(self._repo, self._path, fileid=fileid, |