revlog: eliminate diff and patches functions
authorMatt Mackall <mpm@selenic.com>
Mon, 23 Jul 2007 20:44:08 -0500
changeset 4989 1aaed3d69772
parent 4988 14486eea8e7a
child 4990 4491125c0f21
revlog: eliminate diff and patches functions call mdiff variants directly
mercurial/bundlerepo.py
mercurial/revlog.py
--- a/mercurial/bundlerepo.py	Mon Jul 23 20:44:08 2007 -0500
+++ b/mercurial/bundlerepo.py	Mon Jul 23 20:44:08 2007 -0500
@@ -12,8 +12,7 @@
 
 from node import *
 from i18n import _
-import changegroup, util, os, struct, bz2, tempfile
-
+import changegroup, util, os, struct, bz2, tempfile, mdiff
 import localrepo, changelog, manifest, filelog, revlog
 
 class bundlerevlog(revlog.revlog):
@@ -91,7 +90,7 @@
         elif not self.bundle(rev1) and not self.bundle(rev2):
             return revlog.revlog.revdiff(self, rev1, rev2)
 
-        return self.diff(self.revision(self.node(rev1)),
+        return mdiff.textdiff(self.revision(self.node(rev1)),
                          self.revision(self.node(rev2)))
 
     def revision(self, node):
@@ -115,7 +114,7 @@
 
         while chain:
             delta = self.chunk(chain.pop())
-            text = self.patches(text, [delta])
+            text = mdiff.patches(text, [delta])
 
         p1, p2 = self.parents(node)
         if node != revlog.hash(text, p1, p2):
--- a/mercurial/revlog.py	Mon Jul 23 20:44:08 2007 -0500
+++ b/mercurial/revlog.py	Mon Jul 23 20:44:08 2007 -0500
@@ -830,14 +830,6 @@
         p1, p2 = self.parents(node)
         return hash(text, p1, p2) != node
 
-    def diff(self, a, b):
-        """return a delta between two revisions"""
-        return mdiff.textdiff(a, b)
-
-    def patches(self, t, pl):
-        """apply a list of patches to a string"""
-        return mdiff.patches(t, pl)
-
     def chunk(self, rev, df=None):
         start, length = self.start(rev), self.length(rev)
         if self._inline:
@@ -884,8 +876,8 @@
         if b1 == b2 and rev1 + 1 == rev2:
             return self.chunk(rev2)
         else:
-            return self.diff(self.revision(self.node(rev1)),
-                             self.revision(self.node(rev2)))
+            return mdiff.textdiff(self.revision(self.node(rev1)),
+                                  self.revision(self.node(rev2)))
 
     def revision(self, node):
         """return an uncompressed revision of a given"""
@@ -914,12 +906,8 @@
             self._loadindex(base, rev + 1)
             text = self.chunk(base, df=df)
 
-        bins = []
-        for r in xrange(base + 1, rev + 1):
-            bins.append(self.chunk(r, df=df))
-
-        text = self.patches(text, bins)
-
+        bins = [self.chunk(r, df) for r in xrange(base + 1, rev + 1)]
+        text = mdiff.patches(text, bins)
         p1, p2 = self.parents(node)
         if node != hash(text, p1, p2):
             raise RevlogError(_("integrity check failed on %s:%d")
@@ -998,7 +986,7 @@
         if curr:
             if not d:
                 ptext = self.revision(self.node(prev))
-                d = self.diff(ptext, text)
+                d = mdiff.textdiff(ptext, text)
             data = compress(d)
             l = len(data[1]) + len(data[0])
             dist = l + offset - self.start(base)
@@ -1150,7 +1138,7 @@
                     dfh.flush()
                 ifh.flush()
                 text = self.revision(chain)
-                text = self.patches(text, [delta])
+                text = mdiff.patches(text, [delta])
                 chk = self._addrevision(text, transaction, link, p1, p2, None,
                                         ifh, dfh)
                 if not dfh and not self._inline: