From patchwork Mon Aug 12 16:27:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [11,of,41] basefilectx: move __eq__ from filectx From: Sean Farley X-Patchwork-Id: 2139 Message-Id: <071cc2531b45dae17231.1376324827@laptop.local> To: mercurial-devel@selenic.com Date: Mon, 12 Aug 2013 11:27:07 -0500 # HG changeset patch # User Sean Farley # Date 1376279343 18000 # Sun Aug 11 22:49:03 2013 -0500 # Node ID 071cc2531b45dae172318a9e2cffc212361d6d13 # Parent adb67ffaa74e1ad123156b72de8c22bfe0e564f8 basefilectx: move __eq__ from filectx We also add type checking for extra protection. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -465,10 +465,17 @@ try: return hash((self._path, self._filenode)) except AttributeError: return id(self) + def __eq__(self, other): + try: + return (type(self) == type(other) and self._path == other._path + and self._filenode == other._filenode) + except AttributeError: + return False + class filectx(basefilectx): """A filecontext object makes access to data related to a particular filerevision convenient.""" def __init__(self, repo, path, changeid=None, fileid=None, filelog=None, changectx=None): @@ -514,17 +521,10 @@ # Linkrevs have several serious troubles with filtering that are # complicated to solve. Proper handling of the issue here should be # considered when solving linkrev issue are on the table. return changectx(self._repo.unfiltered(), self._changeid) - def __eq__(self, other): - try: - return (self._path == other._path - and self._filenode == other._filenode) - except AttributeError: - return False - def __ne__(self, other): return not (self == other) def filectx(self, fileid): '''opens an arbitrary revision of the file without