Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revlogutils/deltas.py @ 39511:e72130f58f5d
snapshot: consider all snapshots in the parents' chains
There are no reasons to only consider full snapshot as a possible base for an
intermediate snapshot. Now that the basic principles have been set, we can
start adding more levels of snapshots.
We now consider all snapshots in the parent's chains (full or intermediate).
This creates a chain of intermediate snapshots, each smaller than the previous
one.
# Effect On The Test Repository
In the test repository, we can see a decrease in the revlog size and slightly
shorter delta chain.
However, that approach creates snapshots more frequently, increasing the risk
of ending into problematic cases in very branchy repositories (not triggered
by the test repository). The next changesets will remove that risk by adding
logic that increases deltas reuse.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 07 Sep 2018 11:17:30 -0400 |
parents | 3ca144f1c8dd |
children | 6a53842727c1 |
line wrap: on
line diff
--- a/mercurial/revlogutils/deltas.py Fri Sep 07 11:17:30 2018 -0400 +++ b/mercurial/revlogutils/deltas.py Fri Sep 07 11:17:30 2018 -0400 @@ -661,12 +661,23 @@ yield parents if sparse and parents: + snapshots = collections.defaultdict(list) # map: base-rev: snapshot-rev # See if we can use an existing snapshot in the parent chains to use as # a base for a new intermediate-snapshot - bases = [] + # + # search for snapshot in parents delta chain + # map: snapshot-level: snapshot-rev + parents_snaps = collections.defaultdict(set) for p in parents: - bases.append(deltachain(p)[0]) - yield tuple(sorted(bases)) + for idx, s in enumerate(deltachain(p)): + if not revlog.issnapshot(s): + break + parents_snaps[idx].add(s) + # Test them as possible intermediate snapshot base + # We test them from highest to lowest level. High level one are more + # likely to result in small delta + for idx, snaps in sorted(parents_snaps.items(), reverse=True): + yield tuple(sorted(snaps)) # No suitable base found in the parent chain, search if any full # snapshots emitted since parent's base would be a suitable base for an # intermediate snapshot. @@ -675,8 +686,7 @@ # revisions instead of starting our own. Without such re-use, # topological branches would keep reopening new full chains. Creating # more and more snapshot as the repository grow. - snapfloor = min(bases) + 1 - snapshots = collections.defaultdict(list) + snapfloor = min(parents_snaps[0]) + 1 _findsnapshots(revlog, snapshots, snapfloor) yield tuple(snapshots[nullrev])