Mercurial > hg
view tests/test-eol-clone.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 | 95a615dd77bf |
children | dcaa2df1f688 |
line wrap: on
line source
Testing cloning with the EOL extension $ cat >> $HGRCPATH <<EOF > [extensions] > eol = > > [eol] > native = CRLF > EOF setup repository $ hg init repo $ cd repo $ cat > .hgeol <<EOF > [patterns] > **.txt = native > EOF $ printf "first\r\nsecond\r\nthird\r\n" > a.txt $ hg commit --addremove -m 'checkin' adding .hgeol adding a.txt Test commit of removed .hgeol and how it immediately makes the automatic changes explicit and committable. $ cd .. $ hg clone repo repo-2 updating to branch default 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd repo-2 $ cat a.txt first\r (esc) second\r (esc) third\r (esc) $ hg cat a.txt first second third $ hg remove .hgeol $ touch a.txt * # ensure consistent st dirtyness checks, ignoring dirstate timing $ hg st -v --debug M a.txt R .hgeol $ hg commit -m 'remove eol' $ hg exp # HG changeset patch # User test # Date 0 0 # Thu Jan 01 00:00:00 1970 +0000 # Node ID 3c20c2d90333b6ecdc8f7aa8f9b73223c7c7a608 # Parent 90f94e2cf4e24628afddd641688dfe4cd476d6e4 remove eol diff -r 90f94e2cf4e2 -r 3c20c2d90333 .hgeol --- a/.hgeol Thu Jan 01 00:00:00 1970 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -[patterns] -**.txt = native diff -r 90f94e2cf4e2 -r 3c20c2d90333 a.txt --- a/a.txt Thu Jan 01 00:00:00 1970 +0000 +++ b/a.txt Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +1,3 @@ -first -second -third +first\r (esc) +second\r (esc) +third\r (esc) $ hg push --quiet $ cd .. Test clone of repo with .hgeol in working dir, but no .hgeol in default checkout revision tip. The repo is correctly updated to be consistent and have the exact content checked out without filtering, ignoring the current .hgeol in the source repo: $ cat repo/.hgeol [patterns] **.txt = native $ hg clone repo repo-3 -v --debug linked 7 files updating to branch default resolving manifests branchmerge: False, force: False, partial: False ancestor: 000000000000, local: 000000000000+, remote: 3c20c2d90333 calling hook preupdate.eol: hgext.eol.preupdate a.txt: remote created -> g getting a.txt 1 files updated, 0 files merged, 0 files removed, 0 files unresolved updating the branch cache $ cd repo-3 $ cat a.txt first\r (esc) second\r (esc) third\r (esc) Test clone of revision with .hgeol $ cd .. $ hg clone -r 0 repo repo-4 adding changesets adding manifests adding file changes added 1 changesets with 2 changes to 2 files new changesets 90f94e2cf4e2 updating to branch default 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd repo-4 $ cat .hgeol [patterns] **.txt = native $ cat a.txt first\r (esc) second\r (esc) third\r (esc) $ cd ..