Patchwork [6,of,8] _builddeltainfo: separate diff computation from the collection of other info

login
register
mail settings
Submitter Paul Morelle
Date Jan. 14, 2018, 10:28 a.m.
Message ID <d321149c4918b0c008fc.1515925702@taranis.localdomain>
Download mbox | patch
Permalink /patch/26732/
State Accepted
Headers show

Comments

Paul Morelle - Jan. 14, 2018, 10:28 a.m.
# HG changeset patch
# User Paul Morelle <paul.morelle@octobus.net>
# Date 1515844518 -3600
#      Sat Jan 13 12:55:18 2018 +0100
# Node ID d321149c4918b0c008fc38f318c4759c7c29ba80
# Parent  6e83370fc8befdebc523b92f6f4ff6ce009c97ad
# EXP-Topic refactor-revlog
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r d321149c4918
_builddeltainfo: separate diff computation from the collection of other info

Patch

diff -r 6e83370fc8be -r d321149c4918 mercurial/revlog.py
--- a/mercurial/revlog.py	Fri Jan 12 18:58:44 2018 +0100
+++ b/mercurial/revlog.py	Sat Jan 13 12:55:18 2018 +0100
@@ -1935,20 +1935,26 @@ 
                 raise
         return btext[0]
 
+    def _builddeltadiff(self, base, node, p1, p2, btext, cachedelta, fh, flags):
+        t = self._buildtext(node, p1, p2, btext, cachedelta, fh, flags)
+        if self.iscensored(base):
+            # deltas based on a censored revision must replace the
+            # full content in one patch, so delta works everywhere
+            header = mdiff.replacediffheader(self.rawsize(base), len(t))
+            delta = header + t
+        else:
+            ptext = self.revision(base, _df=fh, raw=True)
+            delta = mdiff.textdiff(ptext, t)
+
+        return delta
+
     def _builddeltainfo(self, node, rev, p1, p2, btext, cachedelta, fh, flags):
         # can we use the cached delta?
         if cachedelta and cachedelta[0] == rev:
             delta = cachedelta[1]
         else:
-            t = self._buildtext(node, p1, p2, btext, cachedelta, fh, flags)
-            if self.iscensored(rev):
-                # deltas based on a censored revision must replace the
-                # full content in one patch, so delta works everywhere
-                header = mdiff.replacediffheader(self.rawsize(rev), len(t))
-                delta = header + t
-            else:
-                ptext = self.revision(rev, _df=fh, raw=True)
-                delta = mdiff.textdiff(ptext, t)
+            delta = self._builddeltadiff(rev, node, p1, p2, btext, cachedelta,
+                                         fh, flags)
         header, data = self.compress(delta)
         deltalen = len(header) + len(data)
         chainbase = self.chainbase(rev)