changeset 22785:abc44fcc9c57

revlog: move references to revlog.hash to inside the revlog class This will make it possible for subclasses to have different hashing schemes when appropriate. I anticipate using this in manifests. Note that there's still one client of mercurial.revlog.hash() outside of revlog: mercurial.context.memctx uses it to construct the file entries in an in-memory manifest. I don't think this will be a problem in the immediate future, so I've left it as-is.
author Augie Fackler <raf@durin42.com>
date Wed, 24 Sep 2014 15:14:44 -0400
parents 0f4e655136ef
children 079a0ed5ee4a
files mercurial/revlog.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Wed Sep 24 15:10:52 2014 -0400
+++ b/mercurial/revlog.py	Wed Sep 24 15:14:44 2014 -0400
@@ -1036,13 +1036,21 @@
         self._cache = (node, rev, text)
         return text
 
+    def hash(self, text, p1, p2):
+        """Compute a node hash.
+
+        Available as a function so that subclasses can replace the hash
+        as needed.
+        """
+        return hash(text, p1, p2)
+
     def _checkhash(self, text, node, rev):
         p1, p2 = self.parents(node)
         self.checkhash(text, p1, p2, node, rev)
         return text
 
     def checkhash(self, text, p1, p2, node, rev=None):
-        if node != hash(text, p1, p2):
+        if node != self.hash(text, p1, p2):
             revornode = rev
             if revornode is None:
                 revornode = templatefilters.short(hex(node))
@@ -1104,7 +1112,7 @@
         if link == nullrev:
             raise RevlogError(_("attempted to add linkrev -1 to %s")
                               % self.indexfile)
-        node = node or hash(text, p1, p2)
+        node = node or self.hash(text, p1, p2)
         if node in self.nodemap:
             return node