Patchwork [10,of,41] basefilectx: move __hash__ from filectx

login
register
mail settings
Submitter Sean Farley
Date Aug. 12, 2013, 4:27 p.m.
Message ID <adb67ffaa74e1ad12315.1376324826@laptop.local>
Download mbox | patch
Permalink /patch/2137/
State Accepted
Commit fe50d21be01adde8c40916e440668955514868c3
Headers show

Comments

Sean Farley - Aug. 12, 2013, 4:27 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1376279259 18000
#      Sun Aug 11 22:47:39 2013 -0500
# Node ID adb67ffaa74e1ad123156b72de8c22bfe0e564f8
# Parent  df530f9dbdc05968658a2ec706ecfc24ca79612e
basefilectx: move __hash__ from filectx

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -459,10 +459,16 @@ 
         return "%s@%s" % (self.path(), short(self.node()))
 
     def __repr__(self):
         return "<%s %s>" % (type(self).__name__, str(self))
 
+    def __hash__(self):
+        try:
+            return hash((self._path, self._filenode))
+        except AttributeError:
+            return id(self)
+
 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):
@@ -508,16 +514,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 __hash__(self):
-        try:
-            return hash((self._path, self._filenode))
-        except AttributeError:
-            return id(self)
-
     def __eq__(self, other):
         try:
             return (self._path == other._path
                     and self._filenode == other._filenode)
         except AttributeError: