Skip to content
Snippets Groups Projects
  1. Sep 16, 2024
    • Matt Harbison's avatar
      typing: add `from __future__ import annotations` to most files · f4733654f144
      Matt Harbison authored
      Now that py36 is no longer supported, we can postpone annotation evaluation.
      This means that the quoting is usually optional (for things imported under the
      guard of `if typing.TYPE_CHECKING:` to avoid circular imports), and there's less
      overhead on startup[1].
      
      There may be some missing here.  I backed out 6000f5b25c9b (which removed the
      `from __future__ import ...` that was supporting py2), reverted the changes in
      `contrib/`, `doc/`, and `tests/`, and then ran:
      
          $ hg status -n --change . | \
              xargs sed -i -e 's/from __future__ import .*$/from __future__ import annotations/'
      
      There were some minor tweaks needed when reviewing (mostly making the spacing
      around the import consistent, and `mercurial/testing/__init__.py` had a
      multiline import that wasn't fully rewritten.
      
      [1] https://docs.python.org/3/whatsnew/3.7.html#pep-563-postponed-evaluation-of-annotations
      f4733654f144
    • Matt Harbison's avatar
      format: add many "missing" comma · 607e94e01851
      Matt Harbison authored
      Black was not adding them until the next changeset introduced a bunch of `from
      __future__ import annotations` to most file. Since it make the next changeset
      hard to read we introduce them in advance.
      607e94e01851
  2. Sep 12, 2024
    • Matt Harbison's avatar
      typing: simplify archive.gz writing and drop a few pytype suppressions · f81e0ce5103a
      Matt Harbison authored
      I was waiting until 3.8 to use `Literal` to fix this, but there's also the ":"
      and "|" characters that are passed along here, meant only for the non-gz archive
      types.  But manipulating what the local caller passes is silly- we know we're
      writing, so just open it for writing.  As an added bonus, PyCharm stops flagging
      the call too (since it doesn't know about pytype suppression comments).
      f81e0ce5103a
    • Matt Harbison's avatar
      typing: explicitly set the return type of `_InnerRevLog.raw_text()` · 8c39ba94acce
      Matt Harbison authored
      Somewhere between cd72a88c5599 and 2fd44b3dcc33, pytype changed the return type
      from `Tuple[_T1, Any, bool]` to `Any`.  Both are wrong.  `mdiff.patches()` is an
      alias for `mpatch.patches()`, which is selected via module policy (and breaks
      the ability to infer the types).  However, `cext`, `cffi`, and `pure`
      implementations all agree it returns bytes.
      8c39ba94acce
    • Matt Harbison's avatar
      typing: add explicit hints for recent pytype regressions · b60f25f00e94
      Matt Harbison authored
      Somewhere between 454feddab720 and cd72a88c5599, pytype changed how it inferred
      the return type in `extdiff.py` from
      
          Tuple[Any, List[Tuple[bytes, Any, os.stat_result]]]
      
      to
      
          Tuple[Any, List[nothing]]
      
      It also changed the return type in `archival.py` from `Any` to `NoReturn`.  Fix
      those up, and also the obvious parameter types while we're here.
      b60f25f00e94
  3. Jun 19, 2024
  4. Sep 12, 2024
  5. Jun 19, 2024
  6. Mar 26, 2024
    • Raphaël Gomès's avatar
      util: make buffer readonly · f5c46c3518a5
      Raphaël Gomès authored
      There is no use of writable buffers anywhere in the code, and this helps us
      make sure we don't get into unsound territory when sharing memory with Rust.
      
      This `toreadonly` method was not available in Python 3.6, but we dropped the
      support for it earlier that week, so no need for any compatibility code.
      f5c46c3518a5
  7. Sep 05, 2024
    • Matt Harbison's avatar
      setup: avoid the deprecated `distutils.spawn.find_executable` · 4dc1fc2b2f3a
      Matt Harbison authored
      I noticed this was flagged with `DeprecationWarning` in py3.12 with `setuptools`
      74.1.2, and it suggested `shutil.which()` instead.  The signatures aren't the
      same, but the additional `mode` argument in the middle of the latter defaults to
      `os.F_OK | os.X_OK`, which maintains the same semantics.
      4dc1fc2b2f3a
    • Matt Harbison's avatar
      setup: drop the hack to disable linker warning 4197 on Windows · 3f0db3b6bf14
      Matt Harbison authored
      I don't see this when building on Windows with py3.8 or py3.12, so either the
      code was fixed, or (more likely) the compiler stopped warning about it some time
      after VS 2008.  If we do have to put this back, it would probably be better to
      put a `#pragma` in a header file somewhere, and avoid `setuptools` technical
      debt.
      3f0db3b6bf14
  8. Sep 10, 2024
  9. Aug 28, 2024
    • Pierre-Yves David's avatar
      ci: add the option to test more Python versions · 243e805e8a2d
      Pierre-Yves David authored
      It seems like a good idea to be able to test the lowest version we support. And
      there have been enougth issue with 3.12 that we need to be able to make sur we
      do not break it. We should probably get a matrix setup for more version and
      flavor, but that is a simple and efficient start.
      243e805e8a2d
  10. Sep 05, 2024
  11. Sep 11, 2024
  12. Sep 12, 2024
  13. Sep 11, 2024
  14. Nov 15, 2023
    • Jörg Sonnenberger's avatar
      archive: defer opening the output until a file is matched · 3b8d92f71d92
      Jörg Sonnenberger authored
      Before, if no file is matched, an error is thrown, but the archive is
      created anyway. When using hgweb, an error 500 is returned as the
      response body already exists when the error is seen.
      
      Afterwards, the archive is created before the first match is emitted.
      If no match is found, no archive is created. This is more consistent
      behavior as an empty archive is not a representable in all output
      formats, e.g. tar archives.
      3b8d92f71d92
  15. Sep 05, 2024
  16. Sep 10, 2024
  17. Sep 06, 2024
  18. Sep 05, 2024
  19. Aug 28, 2024
  20. Jun 30, 2024
  21. Jun 28, 2024
  22. Aug 07, 2024
    • Manuel Jacob's avatar
      merge: sort filemap only if requested by the caller · 23116aefe786
      Manuel Jacob authored
      The name `sorted` refers to a built-in function, which is always true, so the else branch of this if statement was dead code.
      
      Because, with this fix, the function can iterate over the dict items while yielding values, the dict should not change size while the generator is running. Because of that, it is required to re-introduce code that makes a caller copy the filemap before modification, which was removed in 3c783ff08d40 (that changeset also introduced the filemap() method including the bug that’s being fixed by this changeset).
      23116aefe786
  23. Aug 22, 2024
    • Matt Harbison's avatar
      typing: lock in new pytype gains from making revlog related classes typeable · 0338fb200a30
      Matt Harbison authored
      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.)
      0338fb200a30
  24. Aug 20, 2024
Loading