revlog: improve delta generation heuristics for generaldelta
authorSune Foldager <cryo@cyanite.org>
Thu, 12 May 2011 15:24:33 +0200
changeset 14301 f94993769c87
parent 14300 1b8e421d8e42
child 14302 b0f97b2589cc
revlog: improve delta generation heuristics for generaldelta Without this change, pulls (and clones) into a generaldelta repository could generate very inefficient revlogs, the size of which could be at least twice the original size. This was caused by the generated delta chains covering too large distances, causing new chains to be built far too often. This change addresses the problem by forcing a delta against second parent or against the previous revision, when the first parent delta is in danger of creating a long chain.
mercurial/revlog.py
--- a/mercurial/revlog.py	Thu May 12 14:31:07 2011 +0200
+++ b/mercurial/revlog.py	Thu May 12 15:24:33 2011 +0200
@@ -1033,7 +1033,12 @@
         # should we try to build a delta?
         if prev != nullrev:
             if self._generaldelta:
-                d = builddelta(p1r)
+                if p1r >= basecache[1]:
+                    d = builddelta(p1r)
+                elif p2r >= basecache[1]:
+                    d = builddelta(p2r)
+                else:
+                    d = builddelta(prev)
             else:
                 d = builddelta(prev)
             dist, l, data, base, chainbase = d