Move cmp bits from filelog to revlog
authorMatt Mackall <mpm@selenic.com>
Tue, 15 Aug 2006 14:18:13 -0500
changeset 2890 5df3e5cf16bc
parent 2889 20b95aef3fe0
child 2891 95cc73523983
Move cmp bits from filelog to revlog
mercurial/filelog.py
mercurial/revlog.py
--- a/mercurial/filelog.py	Tue Aug 15 14:06:50 2006 -0500
+++ b/mercurial/filelog.py	Tue Aug 15 14:18:13 2006 -0500
@@ -73,18 +73,7 @@
             t2 = self.read(node)
             return t2 == text
 
-        p1, p2 = self.parents(node)
-        h = hash(text, p1, p2)
-
-        return h != node
-
-    def makenode(self, node, text):
-        """calculate a file nodeid for text, descended or possibly
-        unchanged from node"""
-
-        if self.cmp(node, text):
-            return hash(text, node, nullid)
-        return node
+        return revlog.cmp(self, node, text)
 
     def annotate(self, node):
 
--- a/mercurial/revlog.py	Tue Aug 15 14:06:50 2006 -0500
+++ b/mercurial/revlog.py	Tue Aug 15 14:18:13 2006 -0500
@@ -766,6 +766,19 @@
 
         raise RevlogError(_("No match found"))
 
+    def cmp(self, node, text):
+        """compare text with a given file revision"""
+        p1, p2 = self.parents(node)
+        return hash(text, p1, p2) != node
+
+    def makenode(self, node, text):
+        """calculate a file nodeid for text, descended or possibly
+        unchanged from node"""
+
+        if self.cmp(node, text):
+            return hash(text, node, nullid)
+        return node
+
     def diff(self, a, b):
         """return a delta between two revisions"""
         return mdiff.textdiff(a, b)