Mercurial > hg
view tests/test-dirstate-version-fallback.t @ 51721:ed28085827ec
typing: explicitly type some `mercurial.util` eol code to avoid @overload
Unlike the previous commit, this makes a material difference in the generated
stub file- the `pycompat.identity()` aliases generated an @overload like this:
@overload
def fromnativeeol(a: _T0) -> _T0: ...
... which might fail to detect a bad argument, like str. This drops the
@overload for the 3 related methods, so there's a single definition for each.
The `typelib.BinaryIO_Proxy` is used for subclassing (the same as was done in
8147abc05794), so that it is a `BinaryIO` type during type checking, but still
inherits `object` at runtime. That way, we don't need to implement unused
abstract methods.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 19 Jul 2024 16:49:46 -0400 |
parents | 7e5be4a7cda7 |
children |
line wrap: on
line source
$ cat >> $HGRCPATH << EOF > [storage] > dirstate-v2.slow-path=allow > [format] > use-dirstate-v2=no > EOF Set up a v1 repo $ hg init repo $ cd repo $ echo a > a $ touch file-with-somewhat-long-name-to-make-dirstate-v1-bigger-than-v2 $ hg commit -Aqm a $ hg debugrequires | grep dirstate [1] $ ls -1 .hg/dirstate* .hg/dirstate Copy v1 dirstate $ cp .hg/dirstate $TESTTMP/dirstate-v1-backup Upgrade it to v2 $ hg debugupgraderepo -q --config format.use-dirstate-v2=1 --run | grep -E 'added:|removed:' added: dirstate-v2 $ hg debugrequires | grep dirstate dirstate-v2 $ ls -1 .hg/dirstate* .hg/dirstate .hg/dirstate.* (glob) Manually reset to dirstate v1 to simulate an incomplete dirstate-v2 upgrade $ rm .hg/dirstate* $ cp $TESTTMP/dirstate-v1-backup .hg/dirstate There should be no errors, but a v2 dirstate should be written back to disk $ hg st $ ls -1 .hg/dirstate* .hg/dirstate .hg/dirstate.* (glob) Corrupt the dirstate to see how the errors show up to the user $ echo "I ate your data" > .hg/dirstate $ hg st abort: working directory state appears damaged! (no-rhg !) (falling back to dirstate-v1 from v2 also failed) (no-rhg !) abort: Too little data for dirstate: 16 bytes. (rhg !) [255]