Matt Harbison <matt_harbison@yahoo.com> [Mon, 20 Sep 2021 11:05:30 -0400] rev 48013
util: eliminate the possibility of returning None from `versiontuple()`
This fixes the following error flagged by pytype:
File "/mnt/c/Users/Matt/hg/mercurial/extensions.py", line 228, in load: unsupported operand types for > [unsupported-operands]
Primitive types 'Optional[tuple]' and 'curver: Optional[tuple]' are not comparable.
Differential Revision: https://phab.mercurial-scm.org/D11473
Matt Harbison <matt_harbison@yahoo.com> [Mon, 20 Sep 2021 11:03:46 -0400] rev 48012
archival: force a `CompressionError` to bytes before passing to `error.Abort`
I'm not sure what changed before pytype 09-09-2021 (from 04-15-2021), but this
started getting flagged.
This fixes:
File "/mnt/c/Users/Matt/hg/mercurial/archival.py", line 199, in taropen: Function bytestr.__init__ was called with the wrong arguments [wrong-arg-types]
Expected: (self, ints: Iterable[int])
Actually passed: (self, ints: tarfile.CompressionError)
Attributes of protocol Iterable[int] are not implemented on tarfile.CompressionError: __iter__
Differential Revision: https://phab.mercurial-scm.org/D11472
Matt Harbison <matt_harbison@yahoo.com> [Mon, 20 Sep 2021 10:59:26 -0400] rev 48011
parser: force a `ValueError` to bytes before passing to `error.ParseError`
I'm not sure what changed before pytype 09-09-2021 (from 04-15-2021), but this
started getting flagged. I think there's a pytype bug here, because I don't
see how `.lower()` can be getting called on a `ValueError` after it is forced to
a byte string. That's suppressed for now to make progress.
This fixes:
File "/mnt/c/Users/Matt/hg/mercurial/parser.py", line 219, in unescapestr: Function bytestr.__init__ was called with the wrong arguments [wrong-arg-types]
Expected: (self, ints: Iterable[int])
Actually passed: (self, ints: ValueError)
Attributes of protocol Iterable[int] are not implemented on ValueError: __iter__
File "/mnt/c/Users/Matt/hg/mercurial/parser.py", line 219, in unescapestr: No attribute 'lower' on ValueError [attribute-error]
In Union[ValueError, mercurial.pycompat.bytestr]
Differential Revision: https://phab.mercurial-scm.org/D11471
Matt Harbison <matt_harbison@yahoo.com> [Mon, 20 Sep 2021 10:46:35 -0400] rev 48010
util: avoid a name-error warning in the `mmapread` exception handler
Newly caught by pytype 2021-09-09.
File "/mnt/c/Users/Matt/hg/mercurial/util.py", line 458, in mmapread: Name 'fd' is not defined [name-error]
Differential Revision: https://phab.mercurial-scm.org/D11470
Matt Harbison <matt_harbison@yahoo.com> [Mon, 20 Sep 2021 10:45:18 -0400] rev 48009
typing: suppress an name-error warning in `mercurial/windows.py`
Newly caught by pytype 2021-09-09.
Differential Revision: https://phab.mercurial-scm.org/D11469
Matt Harbison <matt_harbison@yahoo.com> [Mon, 20 Sep 2021 10:44:25 -0400] rev 48008
typing: suppress an import-error warning in `mercurial/utils/resourceutil.py`
Newly caught by pytype 2021-09-09.
Differential Revision: https://phab.mercurial-scm.org/D11468
Matt Harbison <matt_harbison@yahoo.com> [Mon, 20 Sep 2021 10:42:38 -0400] rev 48007
encoding: force a few Errors to bytes before passing to `error.Abort`
I'm not sure what changed before pytype 09-09-2021 (from 04-15-2021), but these
started getting flagged. PyCharm also flagged these. This fixes the following:
File "/mnt/c/Users/Matt/hg/mercurial/encoding.py", line 243, in fromlocal: Function Abort.__init__ was called with the wrong arguments [wrong-arg-types]
Expected: (self, message: Union[bytearray, bytes, memoryview], ...)
Actually passed: (self, message: LookupError, ...)
File "/mnt/c/Users/Matt/hg/mercurial/encoding.py", line 309, in lower: Function Abort.__init__ was called with the wrong arguments [wrong-arg-types]
Expected: (self, message: Union[bytearray, bytes, memoryview], ...)
Actually passed: (self, message: LookupError, ...)
File "/mnt/c/Users/Matt/hg/mercurial/encoding.py", line 336, in upperfallback: Function Abort.__init__ was called with the wrong arguments [wrong-arg-types]
Expected: (self, message: Union[bytearray, bytes, memoryview], ...)
Actually passed: (self, message: LookupError, ...)
Called from (traceback):
line 391, in current file
line 348, in get
line 318, in upper
Differential Revision: https://phab.mercurial-scm.org/D11467
Matt Harbison <matt_harbison@yahoo.com> [Tue, 21 Sep 2021 00:16:35 -0400] rev 48006
typing: add a fake `__init__()` to bytestr to distract pytype
I'm not sure what changed before pytype 09-09-2021 (from 04-15-2021), but these
started getting flagged. This wrapping an exception in a `bytestr` pattern has
been flagged before, and I've fixed it then with `stringutil.forcebytestr()`.
But that doesn't work here, because it would create a circular import.
I suspect the issue is `bytes.__new__()` wants `Iterable[int]`, so it just
assumes the subclass will also take that. The referenced pytype bug isn't an
exact match, but seems related and the suggested workaround helps.
The specific warnings fixed are:
File "/mnt/c/Users/Matt/hg/mercurial/encoding.py", line 212, in tolocal: Function bytestr.__init__ was called with the wrong arguments [wrong-arg-types]
Expected: (self, ints: Iterable[int])
Actually passed: (self, ints: LookupError)
Attributes of protocol Iterable[int] are not implemented on LookupError: __iter__
Called from (traceback):
line 353, in current file
File "/mnt/c/Users/Matt/hg/mercurial/encoding.py", line 240, in fromlocal: Function bytestr.__init__ was called with the wrong arguments [wrong-arg-types]
Expected: (self, ints: Iterable[int])
Actually passed: (self, ints: UnicodeDecodeError)
Attributes of protocol Iterable[int] are not implemented on UnicodeDecodeError: __iter__
Differential Revision: https://phab.mercurial-scm.org/D11466
Augie Fackler <augie@google.com> [Mon, 20 Sep 2021 15:51:23 -0400] rev 48005
merge: with stable
Raphaël Gomès <rgomes@octobus.net> [Thu, 09 Sep 2021 10:42:28 +0200] rev 48004
pep-517: remove the `build-backend` key to allow for users to build extensions
PEP 517 changed how projects should define their build dependencies.
The presence of a `pyproject.toml` file changes the behavior of `pip` to
conform to PEP 517.
Since we haven't updated the `setup.py` file yet (I'm not even sure we're not
an edge case which would make it harder/impossible, I have not tried yet), this
is a workaround to
issue6589: it allows users to pass `--no-use-pep517` to pip
to revert to the legacy installer. The build backend is simply assumed to be
the `build_meta:__legacy__` one.
Differential Revision: https://phab.mercurial-scm.org/D11393
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:41:38 +0200] rev 48003
dirstate: drop the `dirstatemap.dropfile` method
All use have been migrated.
Differential Revision: https://phab.mercurial-scm.org/D11443
Pierre-Yves David <pierre-yves.david@octobus.net> [Thu, 16 Sep 2021 15:21:22 +0200] rev 48002
dirstate: use `reset_state` instead of `dropfile` in test-rebuildstate.t
As `dirstatemap.dropfile` is on its way out.
Differential Revision: https://phab.mercurial-scm.org/D11442
Pierre-Yves David <pierre-yves.david@octobus.net> [Thu, 16 Sep 2021 15:20:28 +0200] rev 48001
dirstate: use `reset_state` instead of `dropfile` in largefile
As `dirstatemap.dropfile` is on its way out.
Differential Revision: https://phab.mercurial-scm.org/D11441
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:40:25 +0200] rev 48000
dirstate: use `reset_state` in `rebuild` instead of `dropfile`
As `dirstatemap.dropfile` is on its way out.
Differential Revision: https://phab.mercurial-scm.org/D11440
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:38:24 +0200] rev 47999
dirstate: use `reset_state` to drop file in `update_file_p1`
The `dropfile` function is on its way out.
Differential Revision: https://phab.mercurial-scm.org/D11439
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:36:59 +0200] rev 47998
dirstate: support file tracked nowhere in `reset_state`
This let the dirstatemap decide when to drop files.
Differential Revision: https://phab.mercurial-scm.org/D11438
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:30:06 +0200] rev 47997
dirstate: drop dirstatemap.addfile
All users have been migrated.
Differential Revision: https://phab.mercurial-scm.org/D11437
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:27:57 +0200] rev 47996
dirstate: update the documentation of the dirstatemap API
The API changed so should the documentation.
Differential Revision: https://phab.mercurial-scm.org/D11436
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 12:38:56 +0200] rev 47995
dirstate: drop the `_addpath` method
All user have been migrated.
Differential Revision: https://phab.mercurial-scm.org/D11435
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 12:33:59 +0200] rev 47994
dirstate: remove the `normallookup` function
All use have been migrated.
Differential Revision: https://phab.mercurial-scm.org/D11434
Pierre-Yves David <pierre-yves.david@octobus.net> [Thu, 16 Sep 2021 14:14:33 +0200] rev 47993
dirstate: stop using `_normallookup` in the adddrop extension
That extension is just trying to produce a "corrupted" dirstate.
Differential Revision: https://phab.mercurial-scm.org/D11433
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:12:55 +0200] rev 47992
dirstate: replace the use of `_normallookup` in `rebuild`
Normal lookup is a complicated function that we want to get rid of.
Differential Revision: https://phab.mercurial-scm.org/D11432
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:16:16 +0200] rev 47991
dirstate: replace the use of _normallookup in `setparents`
normal lookup is a complicated function that we want to get rid of.
Differential Revision: https://phab.mercurial-scm.org/D11431
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:05:39 +0200] rev 47990
dirstate: introduce a set_tracked method on "map" and "item"
This move more implementation details withing the DirstateItem itself, which is
what we have been doing for a while.
Differential Revision: https://phab.mercurial-scm.org/D11430
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 11:13:46 +0200] rev 47989
dirstate: fix restoration of "merged" state after a remove
Before this change, "merged" file that get removed and re-added later were
recorded as "from_p2" instead.
This came from
8fe74328f700, a 2014 changeset that start explicitly doing so
for reason I have not been able to fully grasp. The graft test mentioned in
the description are still happy after this changeset.
So this changeset restore what seems to be the intended behavior. Restoring
information as it was before the removal.
Differential Revision: https://phab.mercurial-scm.org/D11429
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 10:20:25 +0200] rev 47988
dirstate: inline the last two `_drop` usage
The function is small and having the associated code directly inline help use to cleanup the dirstate API.
Differential Revision: https://phab.mercurial-scm.org/D11428
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 10:02:11 +0200] rev 47987
dirstate: make a conditionnal easier to read in `setparents`
By grabing `nullid` in the local space, we get the conditionnal to fit in one
line.
Differential Revision: https://phab.mercurial-scm.org/D11427
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 09:50:44 +0200] rev 47986
dirstate: removed the now unused `_add` method
Differential Revision: https://phab.mercurial-scm.org/D11426
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 18:18:16 +0200] rev 47985
dirstate: replace `_add` call in `setparent`
Same logic as the previous changeset, it get us closer to removed older API on
the dirstate.
Differential Revision: https://phab.mercurial-scm.org/D11425
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 15 Sep 2021 09:41:02 +0200] rev 47984
dirstate: directly call the right function in `set_tracked`
This get use closer to removing some older API on the dirstate.
Differential Revision: https://phab.mercurial-scm.org/D11424