Mercurial > hg
view tests/test-cache-abuse.t @ 49652:03792c1ed341
contrib: add a script for adding vendored type stubs to typeshed
I really hate this, but pytype doesn't support PEP 561 and doesn't seem to have
the equivalent of `MYPYPATH` to point to custom stubs. Ignoring the vendored
stubs isn't necessarily harmful, but pytype has been choking on the vendored
attr package after pytype 2022.03.29 with errors like this:
File "/mnt/c/Users/Matt/hg/mercurial/linelog.py", line 52, in __iter__: Built-in function iter was called with the wrong arguments [wrong-arg-types]
Expected: (collection: bytearray)
Actually passed: (collection: mercurial.thirdparty.attr._make._CountingAttr)
File "/mnt/c/Users/Matt/hg/mercurial/dirstateutils/v2.py", line 143, in pack: Built-in function len was called with the wrong arguments [wrong-arg-types]
Expected: (obj: Sized)
Actually passed: (obj: mercurial.thirdparty.attr._make._CountingAttr)
Attributes of protocol Sized are not implemented on mercurial.thirdparty.attr._make._CountingAttr: __len__
File "/mnt/c/Users/Matt/hg/mercurial/dirstateutils/v2.py", line 144, in pack: No attribute 'rfind' on mercurial.thirdparty.attr._make._CountingAttr [attribute-error]
File "/mnt/c/Users/Matt/hg/mercurial/dirstateutils/v2.py", line 146, in pack: Built-in function len was called with the wrong arguments [wrong-arg-types]
Expected: (obj: Sized)
Actually passed: (obj: mercurial.thirdparty.attr._make._CountingAttr)
Attributes of protocol Sized are not implemented on mercurial.thirdparty.attr._make._CountingAttr: __len__
File "/mnt/c/Users/Matt/hg/mercurial/dirstateutils/v2.py", line 152, in pack: No attribute 'v2_data' on mercurial.thirdparty.attr._make._CountingAttr [attribute-error]
File "/mnt/c/Users/Matt/hg/mercurial/util.py", line 2817, in go: unsupported operand type(s) for /: 'count: mercurial.thirdparty.attr._make._CountingAttr' and 'float: float' [unsupported-operands]
No attribute '__truediv__' on 'count: mercurial.thirdparty.attr._make._CountingAttr' or '__rtruediv__' on 'float: float'
Called from (traceback):
line 2981, in __bytes__
This is essentially the same hack we've been using in TortoiseHg to add the
vendored PyQt5 stubs. What I don't understand is pytype *still* generates *.pyi
files under .pytype/pyi/mercurial/thirdparty/attr, even when the package is
explicitly ignored in the pytype command line args. But it avoids the errors,
which means we aren't stuck on pytype==2022.03.29.
https://github.com/google/pytype/issues/151
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 23 Nov 2022 20:50:39 -0500 |
parents | 34a46d48d24e |
children | 0f26ee69cf36 |
line wrap: on
line source
Enable obsolete markers $ cat >> $HGRCPATH << EOF > [experimental] > evolution.createmarkers=True > [phases] > publish=False > EOF Build a repo with some cacheable bits: $ hg init a $ cd a $ echo a > a $ hg ci -qAm0 $ hg tag t1 $ hg book -i bk1 $ hg branch -q b2 $ hg ci -Am1 $ hg tag t2 $ echo dumb > dumb $ hg ci -qAmdumb $ hg debugobsolete b1174d11b69e63cb0c5726621a43c859f0858d7f 1 new obsolescence markers obsoleted 1 changesets $ hg phase -pr t1 $ hg phase -fsr t2 Make a helper function to check cache damage invariants: - command output shouldn't change - cache should be present after first use - corruption/repair should be silent (no exceptions or warnings) - cache should survive deletion, overwrite, and append - unreadable / unwriteable caches should be ignored - cache should be rebuilt after corruption $ damage() { > CMD=$1 > CACHE=.hg/cache/$2 > CLEAN=$3 > hg $CMD > before > test -f $CACHE || echo "not present" > echo bad > $CACHE > test -z "$CLEAN" || $CLEAN > hg $CMD > after > "$RUNTESTDIR/pdiff" before after || echo "*** overwrite corruption" > echo corruption >> $CACHE > test -z "$CLEAN" || $CLEAN > hg $CMD > after > "$RUNTESTDIR/pdiff" before after || echo "*** append corruption" > rm $CACHE > mkdir $CACHE > test -z "$CLEAN" || $CLEAN > hg $CMD > after > "$RUNTESTDIR/pdiff" before after || echo "*** read-only corruption" > test -d $CACHE || echo "*** directory clobbered" > rmdir $CACHE > test -z "$CLEAN" || $CLEAN > hg $CMD > after > "$RUNTESTDIR/pdiff" before after || echo "*** missing corruption" > test -f $CACHE || echo "not rebuilt" > } Beat up tags caches: $ damage "tags --hidden" tags2 $ damage tags tags2-visible $ damage "tag -f t3" hgtagsfnodes1 1 new orphan changesets 1 new orphan changesets 1 new orphan changesets 1 new orphan changesets 1 new orphan changesets Beat up branch caches: $ damage branches branch2-base "rm .hg/cache/branch2-[vs]*" $ damage branches branch2-served "rm .hg/cache/branch2-[bv]*" $ damage branches branch2-visible $ damage "log -r branch(.)" rbc-names-v1 $ damage "log -r branch(default)" rbc-names-v1 $ damage "log -r branch(b2)" rbc-revs-v1 We currently can't detect an rbc cache with unknown names: $ damage "log -qr branch(b2)" rbc-names-v1 --- before * (glob) +++ after * (glob) @@ -1,8 +?,0 @@ (glob) -2:5fb7d38b9dc4 -3:60b597ffdafa -4:b1174d11b69e -5:6354685872c0 -6:5ebc725f1bef -7:7b76eec2f273 -8:ef3428d9d644 -9:ba7a936bc03c *** append corruption