tests: correct Windows output to account for putting repos in `repo` subdir
These were missed in
55c6ebd11cb9, due to being conditionalized and not running
in CI.
tests: use pattern matching to mask `ECONNREFUSED` messages
The second and third one of these in `test-http-proxy.t` was failing on Windows.
The others were found by grep and by failed tests when output was matched and an
attempt was made to emit the mask pattern.
The first clonebundles failure on Windows emitted:
error fetching bundle: [WinError 10061] $ECONNREFUSED$
We should probably stringify that better to get rid of the "[WinError 10061]"
part.
typing: add stub functions for `cext/charencoding`
I'm not sure if it's better to have a separate file, and currently pytype
doesn't really know how to handle these, so it's no help in figuring that out.
Technically, these methods are part of the `mercurial.cext.parsers` module, so
put them into the existing stub until there's a reason to split it out.
interfaces: introduce and use a protocol class for the `charencoding` module
See
f2832de2a46c for details when this was done for the `bdiff` module.
This lets us dump the hack where the `pure` implementation was imported during
the type checking phase to provide signatures for the module methods it
provides. Now the protocol classes are starting to shine, because these methods
are provided by `pure.charencoding` and `cext.parsers`, and references to
`cffi.charencoding` and `cext.charencoding` are forwarded to them as appropriate
by the `policy` module. But none of that matters, as long as the module
returned provides the listed methods.
The interface was copy/pasted from the `pure` module, but `jsonescapeu8fallback`
is omitted because it is accessed from the `pure` module directly when the
escaping fails in the primary module's `jsonescapeu8()`.
debugantivirusrunning: use bytes when opening a vfs file
I noticed this when searching for "base85" to see if anything else in the
previous commit needed to be annotated. This was added in
87047efbc6a6, after
the mass byteification in
687b865b95ad.
interfaces: introduce and use a protocol class for the `base85` module
See
f2832de2a46c for details when this was done for the `bdiff` module.
It looks like PEP-688 removed the special casing of `bytes` being a standin
for any type of `ByteString`, and defines a `typing.Buffer` class (with a
backport in `typing_extensions` for Python prior to 3.12). There's been a lot
of churn in this area with pytype, but recent versions of pytype and PyCharm
recognize this, and e.g. have `mercurial.node.hex()` defined as:
from typing_extensions import Buffer
def hex(data: Buffer, sep: str | bytes = ..., bytes_per_sep: int = ...) -> bytes
This covers `bytes`, `bytearray`, and `memoryview` by default. Both of the C
functions here use `y#` to parse the arguments, which means the arg is a
byte-like object[2], so the args would appear to be better typed as `Buffer`.
However, pytype has a bug that prevents using this from `typing_extensions`[3],
and mypy complained `Unsupported left operand type for + ("memoryview")` in the
pure module on line 37 (meaning it's only a subset of `Buffer`). So hold off on
changing any of that for now.
[1] https://peps.python.org/pep-0688/#no-special-meaning-for-bytes
[2] https://docs.python.org/3/glossary.html#term-bytes-like-object
[3] https://github.com/google/pytype/issues/1772