Mercurial > hg
view relnotes/6.2 @ 51933:f2832de2a46c
interfaces: introduce and use a protocol class for the `bdiff` module
This is allowed by PEP 544[1], and we basically follow the example there. The
class here is copied from `mercurial.pure.bdiff`, and the implementation
removed.
There are several modules that have a few different implementations, and the
implementation chosen is controlled by `HGMODULEPOLICY`. The module is loaded
via `mercurial/policy.py`, and has been inferred by pytype as `Any` up to this
point. Therefore it and PyCharm were blind to all functions on the module, and
their signatures. Also, having multiple instances of the same module allows
their signatures to get out of sync.
Introducing a protocol class allows the loaded module that is stored in a
variable to be given type info, which cascades through the various places it is
used. This change alters 11 *.pyi files, for example. In theory, this would
also allow us to ensure the various implementations of the same module are kept
in alignment- simply import the module in a test module, attempt to pass it to a
function that uses the corresponding protocol as an argument, and run pytype on
it.
In practice, this doesn't work (yet). PyCharm (erroneously) flags imported
modules being passed where a protocol class is used[2]. Pytype has problems the
other way- it fails to detect when a module that doesn't adhere to the protocol
is passed to a protocol argument. The good news is that mypy properly detects
this case. The bad news is that mypy spews a bunch of other errors when
importing even simple modules, like the various `bdiff` modules. Therefore I'm
punting on the tests for now because the type info around a loaded module in
PyCharm is a clear win by itself.
[1] https://peps.python.org/pep-0544/#modules-as-implementations-of-protocols
[2] https://youtrack.jetbrains.com/issue/PY-58679/Support-modules-implementing-protocols
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 28 Sep 2024 19:12:18 -0400 |
parents | f64261762f3d |
children |
line wrap: on
line source
= Mercurial 6.2.2 = * fsmonitor: restore functionality by moving to new dirstate APIs * dirstate-v2: fix data file transaction handling (issue6730) * rust: fix behavior when matching files with multiple includes * rust: widen range of compatible crates to help with packaging * rust-status: ignored directories are now correctly only listed if opted into * automation: improve Windows packaging tooling * contrib: update Mercurial install in bootstrap environment * Remove flakiness in some tests * Improve portability of certain `tar` uses in tests = Mercurial 6.2.1 = * Fix SSL support in Python 3.6 * git: make sure to fsdecode bookmark names everywhere (issue6723) * git: add a missing reset_copy keyword argument to dirstate.set_tracked() * git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472) * packaging: update keyring on Windows to avoid spurious stacktraces * packaging: bump dulwich to 0.20.45 * Fix typos in documentation for debugdiscovery * Miscellaneous improvements of debugdiscovery = Mercurial 6.2rc0 = '''This is the first release to support Python 3.6+ ''only''''' == New Features == * Introduce a way to auto-upgrade a repo for certain requirements (see `hg help config.format`) * filemerge: add support for partial conflict resolution by external tool * contrib: add a partial-merge tool for sorted lists (such as Python imports) * revlog: reorder p1 and p2 when p1 is null and p2 is not while respecting issue6528 * rhg: add support for ignoring all extensions * completion: install completers to conventional locations * revert: ask user to confirm before tracking new file when interactive * Rust implementation now uses the new dirstate API * sslutil: be less strict about which ciphers are allowed when using --insecure * sslutil: support TLSV1_ALERT_PROTOCOL_VERSION reason code * absorb: make `--edit-lines` imply `--apply-changes` * diff: add help text to highlight the ability to do merge diffs * censor: make rhg fall back to python when encountering a censored node * clone: use better names for temp files * debuglock: make the command more useful in non-interactive mode * debugdeltachain: distinct between snapshot and other diffs * debugindex: rename to debugindex debug-revlog-index * Make debug-revlog-index give out more information * sparse: use the rust code even when sparse is present == Bug Fixes == * Python 3 bugfixes * Windows bugfixes * templates: make `firstline` filter not keep '\v', '\f' and similar * rhg: sort unsupported extensions in error message * Improve performance of all functions that extract the first line of a text * crecord: avoid duplicating lines when reverting noeol->eol change * Some config.path options are now discoverable via config * mail: don't complain about a multi-word email.method * bundlespec: do not overwrite bundlespec value with the config one * bundlespec: do not check for `-` in the params portion of the bundlespec * bundlespec: handle the presence of obsmarker part * sparse: start moving away from the global variable for detection of usage * rust-changelog: don't skip empty lines when iterating over changeset lines * narrow: support debugupgraderepo * bundle: quick fix to ludicrous performance penalty * followlines: don't put Unicode directly into the .js file (issue6559) * manifest: improve error message in case for tree manifest * revlog: use %d to format int instead of %lu (issue6565) * revlog: use appropriate format char for int ("i" instead of I") * worker: stop relying on garbage collection to release memoryview * worker: implement _blockingreader.readinto() (issue6444) * worker: avoid potential partial write of pickled data == Backwards Compatibility Changes == * '''Removed Python 2 support''': this includes a lot of cleanup in our codebase, automation, testing, etc. * debugindex: rename to debugindex debug-revlog-index == Miscellaneous == * Fix typos and add missing items from documentation * dirstate-tree: optimize HashMap lookups with raw_entry_mut * Rust dependencies have been upgraded * revlog: rank computation is done by Rust when available * Improve discovery test tooling * Audit the number of queries done in discovery * Improved .hgignore of the mercurial-devel repository itself * Improve test coverage of dirstate-v2 * rust-requirements: allow loading repos with `bookmarksinstore` requirement * Various Rust refactorings to help with revlog management * Improve debugability of Rust structs * Improve unit testing of the Rust dirstatemap * Improve robustness of the Rust dirstatemap to corruption * Improve changelog-v2 upgrade system