# HG changeset patch # User Boris Feld # Date 2018-07-27 17:09:41 # Node ID 8f83a953dddf6bacba069a95221f9285ba9bdb28 # Parent a456c603a83dd99eb64090cf4d5b5a9aec1c9738 revlog: skip over empty revision when looking for delta base There is no point in keeping an empty revision in the middle of a chain since they won't contribute any data. So we filter them out when looking for a valid base delta. diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -743,10 +743,20 @@ class _deltacomputer(object): p2 = revinfo.p2 revlog = self.revlog + deltalength = self.revlog.length + deltaparent = self.revlog.deltaparent + deltainfo = None for candidaterevs in self._getcandidaterevs(p1, p2, cachedelta): nominateddeltas = [] for candidaterev in candidaterevs: + # skip over empty delta (no need to include them in a chain) + while candidaterev != nullrev and not deltalength(candidaterev): + candidaterev = deltaparent(candidaterev) + # no need to try a delta against nullid, this will be handled + # by fulltext later. + if candidaterev == nullrev: + continue # no delta for rawtext-changing revs (see "candelta" for why) if revlog.flags(candidaterev) & REVIDX_RAWTEXT_CHANGING_FLAGS: continue diff --git a/tests/test-generaldelta.t b/tests/test-generaldelta.t --- a/tests/test-generaldelta.t +++ b/tests/test-generaldelta.t @@ -267,7 +267,7 @@ test maxdeltachainspan 51 4 3 50 prev 356 594 611 1.02862 611 0 0.00000 52 4 4 51 p1 58 640 669 1.04531 669 0 0.00000 53 5 1 -1 base 0 0 0 0.00000 0 0 0.00000 - 54 5 2 53 p1 376 640 376 0.58750 376 0 0.00000 + 54 6 1 -1 base 369 640 369 0.57656 369 0 0.00000 $ hg clone --pull source-repo --config experimental.maxdeltachainspan=2800 relax-chain --config format.generaldelta=yes requesting all changes adding changesets @@ -333,7 +333,7 @@ test maxdeltachainspan 51 2 13 17 p1 58 594 739 1.24411 2781 2042 2.76319 52 5 1 -1 base 369 640 369 0.57656 369 0 0.00000 53 6 1 -1 base 0 0 0 0.00000 0 0 0.00000 - 54 6 2 53 p1 376 640 376 0.58750 376 0 0.00000 + 54 7 1 -1 base 369 640 369 0.57656 369 0 0.00000 $ hg clone --pull source-repo --config experimental.maxdeltachainspan=0 noconst-chain --config format.generaldelta=yes requesting all changes adding changesets @@ -399,4 +399,4 @@ test maxdeltachainspan 51 2 13 17 p1 58 594 739 1.24411 2642 1903 2.57510 52 2 14 51 p1 58 640 797 1.24531 2700 1903 2.38770 53 4 1 -1 base 0 0 0 0.00000 0 0 0.00000 - 54 4 2 53 p1 376 640 376 0.58750 376 0 0.00000 + 54 5 1 -1 base 369 640 369 0.57656 369 0 0.00000