Pierre-Yves David <pierre-yves.david@octobus.net> [Tue, 10 Sep 2024 21:19:36 +0200] rev 51876
ci: drop path manipulation that we do not need anymore
The CI image has a squarer setup now.
Pierre-Yves David <pierre-yves.david@octobus.net> [Fri, 06 Sep 2024 02:12:19 +0200] rev 51875
brancing: merge stable into default
Joerg Sonnenberger <joerg@bec.de> [Wed, 28 Aug 2024 23:25:26 +0200] rev 51874
utils: accept bytearray arguments for escapestr
Joerg Sonnenberger <joerg@bec.de> [Sun, 30 Jun 2024 16:02:50 +0200] rev 51873
http: simplify
Joerg Sonnenberger <joerg@bec.de> [Sun, 30 Jun 2024 14:16:43 +0200] rev 51872
http: use urllib's cookie handler
Split the logic for loading the cookies based on the configuration in a
helper function and otherwise use the library implementation directly.
Joerg Sonnenberger <joerg@bec.de> [Sun, 30 Jun 2024 13:22:23 +0200] rev 51871
http: reuse Python's implementation of read/readline/readinto
Since Python 3 already provides a working implementation of readline,
there is no need for our own buffering implementation. Reduce the
code to transfer accounting only.
Joerg Sonnenberger <joerg@bec.de> [Sun, 30 Jun 2024 02:46:53 +0200] rev 51870
debugwireproto: redo logging to also work for https
Joerg Sonnenberger <joerg@bec.de> [Fri, 28 Jun 2024 16:26:06 +0200] rev 51869
urllib2: redo response.readlines addition via class patching
Matt Harbison <matt_harbison@yahoo.com> [Wed, 21 Aug 2024 22:15:05 -0400] rev 51868
typing: lock in new pytype gains from making revlog related classes typeable
These were pretty clean changes in the pyi files from earlier in this series, so
add them to the code to make it more understandable.
There's one more trivial hint that can be added to the return of
`mercurial.revlogutils.rewrite._filelog_from_filename()`, however it needs to be
imported from '..' under the conditional of `typing.TYPE_CHECKING`, and that
seems to confuse the import checker- possibly because there's already an import
block from that level. (I would have expected a message about multiple import
statements in this case, but got one about higher level imports should come
first, no matter where I put the import statement.)
Matt Harbison <matt_harbison@yahoo.com> [Tue, 20 Aug 2024 00:07:05 -0400] rev 51867
typing: add types to `revlog.revlogproblem`
These attrs showed as `Any` after the previous commit made the class visible to
pytype.
Matt Harbison <matt_harbison@yahoo.com> [Mon, 19 Aug 2024 22:46:09 -0400] rev 51866
typing: make the revlog classes known to pytype
These are the same changes as c1d7ac70980b and 45270e286bdc made to dirstate,
for the same reasons.
Matt Harbison <matt_harbison@yahoo.com> [Mon, 19 Aug 2024 22:27:43 -0400] rev 51865
typing: make the manifest classes known to pytype
These are the same changes as c1d7ac70980b and 45270e286bdc made to dirstate,
for the same reasons. The migration away from decorating the classes with
`@interfaceutil.implementer` was started back in 3e9a660b074a, but missed one.
Matt Harbison <matt_harbison@yahoo.com> [Mon, 19 Aug 2024 22:21:16 -0400] rev 51864
typing: make the filelog class known to pytype
These are the same changes as c1d7ac70980b and 45270e286bdc made to dirstate,
for the same reasons.
Matt Harbison <matt_harbison@yahoo.com> [Wed, 21 Aug 2024 17:41:57 -0400] rev 51863
remotefilelog: adapt the `debugindex` command to past API changes
Pytype was missing these problems because it's currently inferring the classes
for `filelog` and `revlog` to be `Any`. When that's fixed, these were flagged,
so fix these first.
The `filelog` class used to subclass `revlog`, but that was changed back in
1541e1a8e87d (with most or all of the "lost" attributes being forwarded to the
embedded `revlog` attribute at that time). These forwarded references were
dropped over time, and this command has been broken at least as far back as
68282a7b29a7 when the `version` field was dropped. Most of the fixes were as
simple as calling the accessor for the embedded `revlog` member, but the general
delta feature detection was a bit more involved- I copied the detection for it
from `mercurial.revlogutils.debug.debug_revlog()`.
Matt Harbison <matt_harbison@yahoo.com> [Wed, 21 Aug 2024 16:13:14 -0400] rev 51862
typing: add type hints to the `opener` attributes and arguments of revlog
When making revlog and filelog classes visible to pytype, it got confused quite
a bit in `mercurial/revlogutils/rewrite.py`, thinking it had a plain `Callable`,
and flagging additional methods on it like `join()` and `rename()`. I couldn't
figure out how it reduced to that (and PyCharm flagged `opener` references as
`Any`), but this makes it happy. So make this change before making the classes
visible.
The vfs class hierarchy is a bit wonky (e.g. `filteredvfs` is not a `vfs`), so
this may need to be revisited with a Protocol class that covers all of the `vfs`
classes. But for now, everything works.
Matt Harbison <matt_harbison@yahoo.com> [Wed, 21 Aug 2024 16:09:22 -0400] rev 51861
remotefilelog: honor the `--format` arg of the `debugindex` command
Flagged by PyCharm while investigating pytype spew. The other `**opts` above
are already accessed as str. I've never used remotefilelog, and don't have a
repo to test this on, so I'm trusting the nearby code.
Matt Harbison <matt_harbison@yahoo.com> [Tue, 20 Aug 2024 22:47:11 -0400] rev 51860
shelve: consistently convert exception to bytes via `stringutil.forcebytestr`
The other two places in this module use this, and past experience shows that
this method does a nicer job. I'm not sure why we're converting to bytes here-
`KeyError` is built-in and will have str attrs, and `RepoLookupError` is a
subclass of the built-in `Exception` class (not `errors.Error`, which is
allegedly the baseclass for all Mercurial exceptions).
Matt Harbison <matt_harbison@yahoo.com> [Tue, 20 Aug 2024 22:34:51 -0400] rev 51859
typing: add type hints to `mercurial.shelve`
Pytype wasn't flagging anything here yet, but PyCharm was really unhappy about
the usage of `state` objects being passed to various methods that accessed attrs
on it, without any obvious attrs on the class because there's no contructor.
Filling that out made PyCharm happy, and a few other things needed to be filled
in to make that easier, so I made a pass over the whole file and filled in the
trivial hints. The other repo, ui, context, matcher, and pats items can be
filled in after the context and match modules are typed.
Matt Harbison <matt_harbison@yahoo.com> [Tue, 20 Aug 2024 18:30:47 -0400] rev 51858
typing: lock in correct changes from pytype 2023.04.11 -> 2023.06.16
There were a handful of other changes to the pyi files generated when updating
pytype locally (and jumping from python 3.8.0 to python 3.10.11), but they were
not as clear (e.g. the embedded type in a list changing from `nothing` to `Any`
or similar). These looked obviously correct, and agreed with PyCharm's thoughts
on the signatures.
Oddly, even though pytype starting inferring `obsutil._getfilteredreason()` as
returning bytes, it (correctly) complained about the None path when it was typed
that way. Instead, raise a ProgrammingError if an unhandled fate is calculated.
(Currently, all possibilities are handled, so this isn't reachable unless
another fate is added in the future.)
Matt Harbison <matt_harbison@yahoo.com> [Tue, 20 Aug 2024 17:46:17 -0400] rev 51857
monotone: replace %s interpolation with appropriate numeric specifiers
The length is an int, and the version is a float. Neither work with bytes on
py3. This was noticed when looking at nearby code after updating pytype changed
some signatures.
Matt Harbison <matt_harbison@yahoo.com> [Tue, 20 Aug 2024 16:32:13 -0400] rev 51856
shelve: raise an error when loading a corrupt state file in an impossible case
The old return statement was flagged by pytype 2023.06.16 running under python
3.10.11. No idea why it isn't caught in CI running the same pytype with py3.7.
This function is only called by `unshelvecmd()` (which first checks that either
`--abort` or `--continue` is specified), and `hgabortunshelve()` and
`hgcontinueunshelve()`, which locally apply `--abort` or `--continue`
respectively. Therefore, there is no other way to call this, and this error
should never be seen, but pytype can't figure that out on its own. Given that
the abort case clears the state, it seems reasonable to defensively code this
and not make that a blanket `else` case, on the off chance a 3rd way of calling
this appears in the future.
Matt Harbison <matt_harbison@yahoo.com> [Tue, 20 Aug 2024 11:18:10 -0400] rev 51855
contrib: print the version of pytype used to do the type checking
This will help with CI. I don't see a way to print the version of python that's
running it. When I tried `head -n 1 $(which pytype)`, the CI run printed:
#!/usr/bin/env bash
Locally, that gives the path to the python interpreter in the venv, so IDK
what's different.
Matt Harbison <matt_harbison@yahoo.com> [Sat, 17 Aug 2024 18:43:23 -0400] rev 51854
typing: create an @overload of `phasecache` ctor to handle the copy case
In `phasecache.copy()`, it calls `self.__class__(None, None, _load=False)`, but
the constuctor is typed to take a non-None repository. For the `_load=False`
case, all args are ignored (and the copy function itself populates the attrs on
the new object), so this isn't an error. For the default `_load=True` case, it
needs a non-None repository. This is the simplest way to handle that duality.
The reason this wasn't being detected is because pytype is confused by the
interface decorators on the `localrepository` class, and is inferring the whole
class as `Any`. (See 3e9a660b074a or c1d7ac70980b) Therefore, the type hint of
`localrepo.localrepository` here was also effectively `Any`, which disabled the
type checking entirely.
This is the first foray into using `typing_extensions` to unlock future typing
features. I think this is safe and reasonable because 1) it is only imported in
the type checking phase (so no need to vendor our own copy), and 2) pytype has
its own copy of `typing_extensions` bundled with it, so no need to alter the
test environment. When run with a version of python that supports the symbol(s)
natively, `typing_extensions` simply re-exports from `typing`, so there
shouldn't be any future headaches with this.
Matt Harbison <matt_harbison@yahoo.com> [Sat, 17 Aug 2024 17:38:35 -0400] rev 51853
typing: declare the `_phasesets` member of `phasecache` to be `Optional`
Something in this area got flagged while making the repository class visible to
pytype (instead of being typed as `Any`). A None assignment to something not
optional is wrong, and when I tried setting it to `{}` to keep it non-Optional,
some tests failed. There are checks for the attr being None elsewhere, so this
seems to have just been an oversight.
Matt Harbison <matt_harbison@yahoo.com> [Fri, 16 Aug 2024 18:11:52 -0400] rev 51852
typing: hide the interface version of `dirstate` during type checking
As noted in the previous commit, the `dirstate` type is still inferred as `Any`
by pytype, including where it is used as a base class for the largefiles
dirstate. That effectively disables most type checking. The problems fixed two
commits ago were flagged by this change.
I'm not at all clear what the benefit of the original type is, but that was what
was used at runtime, so I don't want to change the largefiles base class to the
raw class. Having both a lowercase and camelcase name for the same thing isn't
great, but given that this trivially finds problems without worrying about which
symbol clients may be using, and the non-raw type is useless to pytype anyway,
I'm not going to worry about it.
Matt Harbison <matt_harbison@yahoo.com> [Fri, 16 Aug 2024 18:02:32 -0400] rev 51851
dirstate: remove the interface decorator to help pytype
This is the same change that was made for some of the manifest classes in
3e9a660b074a. Note that `dirstate` is still inferred as `Any`, but at least we
have `DirState` with all of the expected attributes.
Matt Harbison <matt_harbison@yahoo.com> [Fri, 16 Aug 2024 17:58:17 -0400] rev 51850
largefiles: sync up `largefilesdirstate` methods with `dirstate` base class
As it currently stands, pytype infers the `dirstate` class (and anything else
decorated with `@interfaceutil.implementer`) as `Any`. When that is worked
around, it suddenly noticed that most of these methods don't exist in the
`dirstate` class anymore. Since they only called into the missing methods and
there's no test failures, we can assume these are never called, and they can be
dropped.
In addition, PyCharm flagged `set_tracked()` and `_ignore()` as not overriding
a superclass method with the same arguments. The missing default parameter for
the former was the obvious issue. I'm guessing that the latter was named wrong
because while there is `_ignore()` in the base class, it takes no arguments and
returns a matcher. The `_ignorefiles()` superclass method also takes no args,
and returns a list of bytes. The `_ignorefileandline()` superclass method DOES
take a file, but returns a tuple. Therefore, the closest match is `_dirignore()`,
which takes a file AND returns a bool. No idea why this needs to be overridden
though.
Arseniy Alekseyev <aalekseyev@janestreet.com> [Fri, 16 Aug 2024 11:12:19 +0100] rev 51849
sparse: reliably avoid writing to store without a lock
With the code as written before this patch we can still end up writing to
store in `debugsparse`. Obviously we'll write to it if by accident a store
requirement is modified, but more importantly we write to it if another
concurrent transaction modifies the requirements file on disk.
We can't rule this out since we're not holding the store lock,
so it's better to explicitly pass a permission to write instead
of inferring it based on file contents.
Arseniy Alekseyev <aalekseyev@janestreet.com> [Thu, 15 Aug 2024 13:52:14 +0100] rev 51848
debugsparse: stop taking the store lock
debugsparse is a workspace-only opperation, or it better be workspace-only.
Let's make it to stop taking the store lock.
Arseniy Alekseyev <aalekseyev@janestreet.com> [Thu, 15 Aug 2024 14:54:22 +0100] rev 51847
scmutils: read the requires file before writing to avoid unnecessary rewrite
This lets us get away without the repo lock in situations where we need
to write requirements, but we know we're not changing the store requirements.