Mercurial > hg
view tests/test-remotefilelog-log.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 | 2338eab5f8b7 |
children | 84a93fa7ecfd |
line wrap: on
line source
#require no-windows $ . "$TESTDIR/remotefilelog-library.sh" $ hg init master $ cd master $ cat >> .hg/hgrc <<EOF > [remotefilelog] > server=True > EOF $ echo x > x $ hg commit -qAm x $ mkdir dir $ echo y > dir/y $ hg commit -qAm y $ cd .. Shallow clone from full $ hgcloneshallow ssh://user@dummy/master shallow --noupdate streaming all changes 2 files to transfer, 473 bytes of data transferred 473 bytes in * seconds (*/sec) (glob) searching for changes no changes found $ cd shallow $ cat .hg/requires dotencode exp-remotefilelog-repo-req-1 fncache generaldelta revlogv1 sparserevlog store $ hg update 2 files updated, 0 files merged, 0 files removed, 0 files unresolved 2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) Log on a file without -f $ hg log dir/y warning: file log can be slow on large repos - use -f to speed it up changeset: 1:2e73264fab97 tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: y Log on a file with -f $ hg log -f dir/y changeset: 1:2e73264fab97 tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: y Log on a file with kind in path $ hg log -r "filelog('path:dir/y')" changeset: 1:2e73264fab97 tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: y Log on multiple files with -f $ hg log -f dir/y x changeset: 1:2e73264fab97 tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: y changeset: 0:b292c1e3311f user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: x Log on a directory $ hg log dir changeset: 1:2e73264fab97 tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: y Log on a file from inside a directory $ cd dir $ hg log y warning: file log can be slow on large repos - use -f to speed it up changeset: 1:2e73264fab97 tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: y Log on a file via -fr $ cd .. $ hg log -fr tip dir/ --template '{rev}\n' 1 Trace renames $ hg mv x z $ hg commit -m move $ hg log -f z -T '{desc} {file_copies}\n' -G @ move z (x) : o x Verify remotefilelog handles rename metadata stripping when comparing file sizes $ hg debugrebuilddirstate $ hg status