Mercurial > hg
view tests/test-transaction-rollback-on-revlog-split.t @ 48014:0dc4cc654d96
typing: drop annotations on `mercurial/logcmdutil.walkopts` attributes
Pytype 2021-09-09 must have learned some things about `@attr`, because while
these were presumably required to help it before (c1d0f83d62c4::9a26fea2b518 and
c11099cc1de4::224c786f4fce), these instances now get flagged as an assignment
mismatch:
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 717, in walkopts: Type annotation for pats does not match type of assignment [annotation-type-mismatch]
Annotation: List[bytes]
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 718, in walkopts: Type annotation for opts does not match type of assignment [annotation-type-mismatch]
Annotation: Dict[bytes, Any]
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 722, in walkopts: Type annotation for revspec does not match type of assignment [annotation-type-mismatch]
Annotation: List[bytes]
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 725, in walkopts: Type annotation for bookmarks does not match type of assignment [annotation-type-mismatch]
Annotation: List[bytes]
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 726, in walkopts: Type annotation for branches does not match type of assignment [annotation-type-mismatch]
Annotation: List[bytes]
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 727, in walkopts: Type annotation for date does not match type of assignment [annotation-type-mismatch]
Annotation: Optional[bytes]
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 728, in walkopts: Type annotation for keywords does not match type of assignment [annotation-type-mismatch]
Annotation: List[bytes]
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 729, in walkopts: Type annotation for no_merges does not match type of assignment [annotation-type-mismatch]
Annotation: bool
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 730, in walkopts: Type annotation for only_merges does not match type of assignment [annotation-type-mismatch]
Annotation: bool
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 731, in walkopts: Type annotation for prune_ancestors does not match type of assignment [annotation-type-mismatch]
Annotation: List[bytes]
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 732, in walkopts: Type annotation for users does not match type of assignment [annotation-type-mismatch]
Annotation: List[bytes]
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 735, in walkopts: Type annotation for include_pats does not match type of assignment [annotation-type-mismatch]
Annotation: List[bytes]
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 736, in walkopts: Type annotation for exclude_pats does not match type of assignment [annotation-type-mismatch]
Annotation: List[bytes]
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 739, in walkopts: Type annotation for follow does not match type of assignment [annotation-type-mismatch]
Annotation: int
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 743, in walkopts: Type annotation for force_changelog_traversal does not match type of assignment [annotation-type-mismatch]
Annotation: bool
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 747, in walkopts: Type annotation for filter_revisions_by_pats does not match type of assignment [annotation-type-mismatch]
Annotation: bool
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 750, in walkopts: Type annotation for sort_revisions does not match type of assignment [annotation-type-mismatch]
Annotation: Optional[bytes]
Assignment: mercurial.thirdparty.attr._make._CountingAttr
File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 753, in walkopts: Type annotation for limit does not match type of assignment [annotation-type-mismatch]
Annotation: Optional[int]
Assignment: mercurial.thirdparty.attr._make._CountingAttr
Differential Revision: https://phab.mercurial-scm.org/D11474
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 20 Sep 2021 11:22:27 -0400 |
parents | 0fb328bb2459 |
children | f38ae2d7390e |
line wrap: on
line source
Test correctness of revlog inline -> non-inline transition ---------------------------------------------------------- Helper extension to intercept renames. $ cat > $TESTTMP/intercept_rename.py << EOF > import os > import sys > from mercurial import extensions, util > > def extsetup(ui): > def close(orig, *args, **kwargs): > path = util.normpath(args[0]._atomictempfile__name) > if path.endswith(b'/.hg/store/data/file.i'): > os._exit(80) > return orig(*args, **kwargs) > extensions.wrapfunction(util.atomictempfile, 'close', close) > EOF Test offset computation to correctly factor in the index entries themselve. Also test that the new data size has the correct size if the transaction is aborted after the index has been replaced. Test repo has one small, one moderate and one big change. The clone has the small and moderate change and will transition to non-inline storage when adding the big change. $ hg init troffset-computation --config format.revlog-compression=none $ cd troffset-computation $ printf '%20d' '1' > file $ hg commit -Aqm_ $ printf '%1024d' '1' > file $ hg commit -Aqm_ $ dd if=/dev/zero of=file bs=1k count=128 > /dev/null 2>&1 $ hg commit -Aqm_ $ cd .. $ hg clone -r 1 troffset-computation troffset-computation-copy --config format.revlog-compression=none -q $ cd troffset-computation-copy Reference size: $ f -s .hg/store/data/file* .hg/store/data/file.i: size=1174 $ cat > .hg/hgrc <<EOF > [hooks] > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme > EOF #if chg $ hg pull ../troffset-computation pulling from ../troffset-computation [255] #else $ hg pull ../troffset-computation pulling from ../troffset-computation [80] #endif $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file | tail -1 data/file.i 128 The first file.i entry should match the size above. The first file.d entry is the temporary record during the split, the second entry after the split happened. The sum of the second file.d and the second file.i entry should match the first file.i entry. $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file data/file.i 1174 data/file.d 0 data/file.d 1046 data/file.i 128 $ hg recover rolling back interrupted transaction (verify step skipped, run `hg verify` to check your repository content) $ f -s .hg/store/data/file* .hg/store/data/file.d: size=1046 .hg/store/data/file.i: size=128 $ hg tip changeset: 1:3ce491143aec tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: _ $ hg verify -q warning: revlog 'data/file.d' not in fncache! 1 warnings encountered! hint: run "hg debugrebuildfncache" to recover from corrupt fncache $ hg debugrebuildfncache --only-data adding data/file.d 1 items added, 0 removed from fncache $ hg verify -q $ cd .. Now retry the procedure but intercept the rename of the index and check that the journal does not contain the new index size. This demonstrates the edge case where the data file is left as garbage. $ hg clone -r 1 troffset-computation troffset-computation-copy2 --config format.revlog-compression=none -q $ cd troffset-computation-copy2 $ cat > .hg/hgrc <<EOF > [extensions] > intercept_rename = $TESTTMP/intercept_rename.py > [hooks] > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme > EOF #if chg $ hg pull ../troffset-computation pulling from ../troffset-computation [255] #else $ hg pull ../troffset-computation pulling from ../troffset-computation [80] #endif $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file data/file.i 1174 data/file.d 0 data/file.d 1046 $ hg recover rolling back interrupted transaction (verify step skipped, run `hg verify` to check your repository content) $ f -s .hg/store/data/file* .hg/store/data/file.d: size=1046 .hg/store/data/file.i: size=1174 $ hg tip changeset: 1:3ce491143aec tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: _ $ hg verify -q $ cd .. Repeat the original test but let hg rollback the transaction. $ hg clone -r 1 troffset-computation troffset-computation-copy-rb --config format.revlog-compression=none -q $ cd troffset-computation-copy-rb $ cat > .hg/hgrc <<EOF > [hooks] > pretxnchangegroup = false > EOF $ hg pull ../troffset-computation pulling from ../troffset-computation searching for changes adding changesets adding manifests adding file changes transaction abort! rollback completed abort: pretxnchangegroup hook exited with status 1 [40] $ f -s .hg/store/data/file* .hg/store/data/file.d: size=1046 .hg/store/data/file.i: size=128 $ hg tip changeset: 1:3ce491143aec tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: _ $ hg verify -q warning: revlog 'data/file.d' not in fncache! 1 warnings encountered! hint: run "hg debugrebuildfncache" to recover from corrupt fncache $ cd ..