# HG changeset patch # User Augie Fackler # Date 2014-09-24 19:14:44 # Node ID abc44fcc9c57c83d65501aa18940674a7426538f # Parent 0f4e655136eff6a80d9947e008aaf92e6b06e8f6 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. diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -1036,13 +1036,21 @@ class revlog(object): 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 @@ class revlog(object): 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