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.
--- 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