Skip to content
Snippets Groups Projects
  1. Jul 21, 2023
  2. Jul 13, 2023
  3. Jul 19, 2023
  4. Jul 12, 2023
  5. Jun 28, 2023
    • kiilerix's avatar
      extensions: imp module is removed in Python 3.12 - use importlib to load files · 19108906
      kiilerix authored
      imp has been deprecated for a long time, and has finally been removed in Python
      3.12 .
      
      imp was only used for loading extensions that has been specified with direct
      .py path or path to a package directory. The same use cases can be achieved
      quite simple with importlib, , possiby with small changes in corner cases with
      undefined behaviour, such as extensions without .py source.
      
      There might also be corner cases and undefined behaviour around use of
      sys.modules and reloading.
      19108906
  6. Jun 27, 2023
    • kiilerix's avatar
      utils: imp module is removed in Python 3.12 - get is_frozen() from _imp · 847f703a
      kiilerix authored
      imp has been deprecated for a long time, and has finally been removed in Python
      3.12 .
      
      The successor importlib is using the same internal _imp module as imp, but
      doesn't expose it's is_frozen. Using the internal function directly seems like
      the cleanest solution.
      
      Another alternative to
        imp.is_frozen("__main__")
      is
        sys.modules['__main__'].__spec__.origin == 'frozen'
      but that seems even more internal and fragile.
      847f703a
    • kiilerix's avatar
      extensions: address ast deprecations introduced in Python 3.12 · b9eb65a1
      kiilerix authored
      Tests would fail with:
        .../mercurial/extensions.py:910: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
          if isinstance(a, ast.Str):
        .../mercurial/extensions.py:912: DeprecationWarning: ast.Bytes is deprecated and will be removed in Python 3.14; use ast.Constant instead
          elif isinstance(a, ast.Bytes):
        .../mercurial/extensions.py:913: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
          name = a.s
      b9eb65a1
    • kiilerix's avatar
      vfs: handle shutil.rmtree deprecation of onerror in Python 3.12 · f173c2c2
      kiilerix authored
      Tests would fail with warnings:
      
        .../mercurial/vfs.py:289: DeprecationWarning: onerror argument is deprecated, use onexc instead
      
      The excinfo changed slightly, but we don't use it anyway.
      f173c2c2
    • kiilerix's avatar
      tests: fix sortdict doctest with Python 3.12 · a2df7485
      kiilerix authored
      The output of OrderedDict changed to use plain dict syntax:
      
        $ python3.11 -c "import collections;print(collections.OrderedDict([('a', 0), ('b', 1)]))"
        OrderedDict([('a', 0), ('b', 1)])
      
        $ python3.12 -c "import collections;print(collections.OrderedDict([('a', 0), ('b', 1)]))"
        OrderedDict({'a': 0, 'b': 1})
      a2df7485
    • kiilerix's avatar
      utils: stop using datetime.utcfromtimestamp() deprecated in Python 3.12 · faccec1e
      kiilerix authored
      Python3.12 made tests fail with warnings:
        DeprecationWarning: datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.fromtimestamp(timestamp, datetime.UTC).
      
      Computing the diff while in timestamp seconds seems to preserve to the original
      intent from ae04af1ce78d.
      
      It would be nice to have some doctest coverage of this, with the problematic
      corner cases that has popped up over time...
      faccec1e
  7. Jul 06, 2023
  8. Mar 30, 2023
    • Georges Racinet's avatar
      rust-revlog: fix incorrect results with NULL_NODE prefixes · bca40373
      Georges Racinet authored
      In case a short hash is a prefix of `NULL_NODE`, the correct revision
      number lookup is `NULL_REVISION` only if there is no match in the nodemap.
      Indeed, if there is a single nodemap match, then it is an ambiguity with the
      always matching `NULL_NODE`.
      
      Before this change, using the Mercurial development repository as a testbed (it
      has public changesets with node ID starting with `0005` and `0009`), this is
      what `rhg` did (plain `hg` provided for reference)
      
      ```
      $ rust/target/debug/rhg cat -r 000 README
      README: no such file in rev 000000000000
      $ hg cat -r 000 README
      abort: ambiguous revision identifier: 000
      ```
      
      Here is the expected output for `rhg` on ambiguous prefixes (again, before
      this change):
      
      ```
      $ rust/target/debug/rhg cat -r 0001 README
      abort: ambiguous revision identifier: 0001
      ```
      
      The test provided by 8c29af0f6d6e in `test-rhg.t` could become flaky with
      this change, unless all hashes are fixed. We expect reviewers to be more
      sure about that than we are.
      bca40373
    • Georges Racinet's avatar
      rust-revlog: split out method for `rev_from_node` without persistent nodemap · 0159b014
      Georges Racinet authored
      This will make easier for the bug fix that is about to come.
      0159b014
  9. Jun 08, 2023
  10. Jul 04, 2023
  11. Jul 03, 2023
  12. Jun 27, 2023
  13. Jun 26, 2023
    • kiilerix's avatar
      hgweb: drop references to deprecated cgitb · d5cd1fd6
      kiilerix authored
      cgitb is going away and gives warnings when importing, and that make tests
      fail:
        $TESTTMP/hgweb.cgi:5: DeprecationWarning: 'cgitb' is deprecated and slated for removal in Python 3.13
      
      The lack of a "nice" high level error handler is not a huge problem, neither
      for users (where it is disabled anyway) or for tests (where we don't use a
      browser and the plain tracebacks often are more readable). It is inevitable
      that it is going away, and there is no obvious alternative. Remove it and move
      on.
      d5cd1fd6
  14. Jun 27, 2023
  15. Mar 23, 2023
    • kiilerix's avatar
      tests: use simple mock smtp server instead of deprecated asyncore smtpd · b3a5af04
      kiilerix authored
      test-patchbomb-tls.t would fail with:
        .../hg/tests/dummysmtpd.py:6: DeprecationWarning: The asyncore module is deprecated and will be removed in Python 3.12. The recommended replacement is asyncio
          import asyncore
        .../hg/tests/dummysmtpd.py:8: DeprecationWarning: The smtpd module is deprecated and unmaintained and will be removed in Python 3.12.  Please see aiosmtpd (https://aiosmtpd.readthedocs.io/) for the recommended replacement.
          import smtpd
      
      The recommended migration path to the standalone asiosmtpd would be overkill.
      
      The tests do not need a full smtp server - we can just use a very simple mock
      hack to preserve the existing test coverage.
      b3a5af04
  16. Jun 26, 2023
  17. Mar 23, 2023
  18. Jun 27, 2023
    • kiilerix's avatar
      demandimport: don't delay _distutils_hack import · 80c8dcfb
      kiilerix authored
      test-demandimport.py would fail on 'import distutils.msvc9compiler' because
      warnings:
        /usr/lib/python3.11/site-packages/_distutils_hack/__init__.py:18: UserWarning: Distutils was imported before Setuptools, but importing Setuptools also replaces the `distutils` module in `sys.modules`. This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly, ensure that setuptools is installed in the traditional way (e.g. not an editable install), and/or make sure that setuptools is always imported before distutils.
          warnings.warn(
        /usr/lib/python3.11/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils.
          warnings.warn("Setuptools is replacing distutils.")
      
      Telling demandimport to ignore this module will allow the hack to work as
      intended.
      
      Note:
      
      The test for distutils.msvc9compiler comes from 2205d00b6d2b. But since then,
      distutils is going away, and setuptools has moved forward and is replacing it.
      It is unclear exactly what is being tested here and how setuptools should
      depended on msvc9compiler. The test might no longer be relevant.
      80c8dcfb
  19. Mar 22, 2023
    • kiilerix's avatar
      tests: update test-remotefilelog-gc.t for Python 3.11 · 8037ddac
      kiilerix authored
      The test output changed because test coverage changed because normpath changed:
      
        $ python3.10 -c 'import os; print(repr(os.path.normpath("asdas\0das")))'
        'asdas\x00das'
      
        $ python3.11 -c 'import os; print(repr(os.path.normpath("asdas\0das")))'
        'asdas'
      8037ddac
  20. Jun 26, 2023
Loading