Mercurial > hg
view tests/test-strip-cross.t @ 42377:0546ead39a7e stable
manifest: avoid corruption by dropping removed files with pure (issue5801)
Previously, removed files would simply be marked by overwriting the first byte
with NUL and dropping their entry in `self.position`. But no effort was made to
ignore them when compacting the dictionary into text form. This allowed them to
slip into the manifest revision, since the code seems to be trying to minimize
the string operations by copying as large a chunk as possible. As part of this,
compact() walks the existing text based on entries in the `positions` list, and
consumed everything up to the next position entry. This typically resulted in
a ValueError complaining about unsorted manifest entries.
Sometimes it seems that files do get dropped in large repos- it seems to
correspond to there being a new entry that would take the same slot. A much
more trivial problem is that if the only changes were removals, `_compact()`
didn't even run because `__delitem__` doesn't add anything to `self.extradata`.
Now there's an explicit variable to flag this, both to allow `_compact()` to
run, and to avoid searching the manifest in cases where there are no removals.
In practice, this behavior was mostly obscured by the check in fastdelta() which
takes a different path that explicitly drops removed files if there are fewer
than 1000 changes. However, timeless has a repo where after rebasing tens of
commits, a totally different path[1] is taken that bypasses the change count
check and hits this problem.
[1] https://www.mercurial-scm.org/repo/hg/file/2338bdea4474/mercurial/manifest.py#l1511
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 23 May 2019 21:54:24 -0400 |
parents | f1186c292d03 |
children | f78f7448a969 |
line wrap: on
line source
test stripping of filelogs where the linkrev doesn't always increase $ echo '[extensions]' >> $HGRCPATH $ echo 'strip =' >> $HGRCPATH $ hg init orig $ cd orig $ commit() > { > hg up -qC null > count=1 > for i in "$@"; do > for f in $i; do > echo $count > $f > done > count=`expr $count + 1` > done > hg commit -qAm "$*" > } 2 1 0 2 0 1 2 $ commit '201 210' $ commit '102 120' '210' $ commit '021' $ commit '201' '021 120' $ commit '012 021' '102 201' '120 210' $ commit 'manifest-file' $ commit '102 120' '012 210' '021 201' $ commit '201 210' '021 120' '012 102' $ HGUSER=another-user; export HGUSER $ commit 'manifest-file' $ commit '012' 'manifest-file' $ cd .. $ hg clone -q -U -r -1 -r -2 -r -3 -r -4 -r -6 orig crossed $ cd crossed $ hg debugindex --manifest rev linkrev nodeid p1 p2 0 0 6f105cbb914d 000000000000 000000000000 1 3 1b55917b3699 000000000000 000000000000 2 1 8f3d04e263e5 000000000000 000000000000 3 2 f0ef8726ac4f 000000000000 000000000000 4 4 0b76e38b4070 000000000000 000000000000 $ for i in 012 021 102 120 201 210 manifest-file; do > echo $i > hg debugindex $i > echo > done 012 rev linkrev nodeid p1 p2 0 0 b8e02f643373 000000000000 000000000000 1 1 5d9299349fc0 000000000000 000000000000 2 2 2661d26c6496 000000000000 000000000000 021 rev linkrev nodeid p1 p2 0 0 b8e02f643373 000000000000 000000000000 1 2 5d9299349fc0 000000000000 000000000000 2 1 2661d26c6496 000000000000 000000000000 102 rev linkrev nodeid p1 p2 0 1 b8e02f643373 000000000000 000000000000 1 0 5d9299349fc0 000000000000 000000000000 2 2 2661d26c6496 000000000000 000000000000 120 rev linkrev nodeid p1 p2 0 1 b8e02f643373 000000000000 000000000000 1 2 5d9299349fc0 000000000000 000000000000 2 0 2661d26c6496 000000000000 000000000000 201 rev linkrev nodeid p1 p2 0 2 b8e02f643373 000000000000 000000000000 1 0 5d9299349fc0 000000000000 000000000000 2 1 2661d26c6496 000000000000 000000000000 210 rev linkrev nodeid p1 p2 0 2 b8e02f643373 000000000000 000000000000 1 1 5d9299349fc0 000000000000 000000000000 2 0 2661d26c6496 000000000000 000000000000 manifest-file rev linkrev nodeid p1 p2 0 3 b8e02f643373 000000000000 000000000000 1 4 5d9299349fc0 000000000000 000000000000 $ cd .. $ for i in 0 1 2 3 4; do > hg clone -q -U --pull crossed $i > echo "% Trying to strip revision $i" > hg --cwd $i strip $i > echo "% Verifying" > hg --cwd $i verify > echo > done % Trying to strip revision 0 saved backup bundle to $TESTTMP/0/.hg/strip-backup/*-backup.hg (glob) % Verifying checking changesets checking manifests crosschecking files in changesets and manifests checking files checked 4 changesets with 15 changes to 7 files % Trying to strip revision 1 saved backup bundle to $TESTTMP/1/.hg/strip-backup/*-backup.hg (glob) % Verifying checking changesets checking manifests crosschecking files in changesets and manifests checking files checked 4 changesets with 14 changes to 7 files % Trying to strip revision 2 saved backup bundle to $TESTTMP/2/.hg/strip-backup/*-backup.hg (glob) % Verifying checking changesets checking manifests crosschecking files in changesets and manifests checking files checked 4 changesets with 14 changes to 7 files % Trying to strip revision 3 saved backup bundle to $TESTTMP/3/.hg/strip-backup/*-backup.hg (glob) % Verifying checking changesets checking manifests crosschecking files in changesets and manifests checking files checked 4 changesets with 19 changes to 7 files % Trying to strip revision 4 saved backup bundle to $TESTTMP/4/.hg/strip-backup/*-backup.hg (glob) % Verifying checking changesets checking manifests crosschecking files in changesets and manifests checking files checked 4 changesets with 19 changes to 7 files