revlog: choose best delta for parentdelta (issue2466) stable
authorMatt Mackall <mpm@selenic.com>
Sat, 30 Oct 2010 02:47:34 -0500
branchstable
changeset 12890 b1c839659140
parent 12889 5482c6b826f4
child 12891 b69fd38a034e
revlog: choose best delta for parentdelta (issue2466) When parentdelta is enabled, we choose the delta that has the minimum distance to its base. Otherwise, base may be sufficiently far away to require a full version, resulting in greatly reduced compression.
mercurial/revlog.py
--- a/mercurial/revlog.py	Sat Oct 30 02:47:34 2010 -0500
+++ b/mercurial/revlog.py	Sat Oct 30 02:47:34 2010 -0500
@@ -1194,15 +1194,14 @@
         d = None
         p1r, p2r = self.rev(p1), self.rev(p2)
 
-        if self._parentdelta:
-            deltarev, deltanode = p1r, p1
-            flags = REVIDX_PARENTDELTA
-        else:
-            deltarev, deltanode = prev, self.node(prev)
-
         # should we try to build a delta?
-        if deltarev != nullrev:
-            d = builddelta(deltarev)
+        if prev != nullrev:
+            d = builddelta(prev)
+            if self._parentdelta and prev != p1r:
+                d2 = builddelta(p1r)
+                if d2 < d:
+                    d = d2
+                    flags = REVIDX_PARENTDELTA
             dist, l, data, base = d
 
         # full versions are inserted when the needed deltas