Add code to retrieve or construct a revlog delta
authormpm@selenic.com
Fri, 20 May 2005 17:40:24 -0800
changeset 119 c7a66f9752a4
parent 118 a0e57df96e96
child 120 bae6f0328f63
Add code to retrieve or construct a revlog delta
mercurial/revlog.py
--- a/mercurial/revlog.py	Fri May 20 17:38:01 2005 -0800
+++ b/mercurial/revlog.py	Fri May 20 17:40:24 2005 -0800
@@ -188,6 +188,18 @@
     def patches(self, t, pl):
         return mdiff.patches(t, pl)
 
+    def delta(self, node):
+        r = self.rev(node)
+        b = self.base(r)
+        if r == b:
+            return self.diff(self.revision(self.node(r - 1)),
+                             self.revision(node))
+        else:
+            f = self.opener(self.datafile)
+            f.seek(self.start(r))
+            data = f.read(self.length(r))
+        return decompress(data)
+
     def revision(self, node):
         if node == nullid: return ""
         if self.cache and self.cache[0] == node: return self.cache[2]