Skip to content
Snippets Groups Projects
  1. Dec 16, 2021
  2. Dec 17, 2021
  3. Dec 15, 2021
    • Matt Harbison's avatar
      pytype: stop excluding ssutil.py · 08af0adc
      Matt Harbison authored
      Pytype simply can't distinguish the type for this one entry's value from the
      other values:
      
        File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 142, in _hostsettings:
            No attribute 'append' on None [attribute-error]
          In Optional[Union[Any, List[nothing], bool, bytes]]
        File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 142, in _hostsettings:
            No attribute 'append' on bool [attribute-error]
          In Optional[Union[Any, List[nothing], bool, bytes]]
        File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 142, in _hostsettings:
            No attribute 'append' on bytes [attribute-error]
          In Optional[Union[Any, List[nothing], bool, bytes]]
        File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 147, in _hostsettings:
            No attribute 'append' on None [attribute-error]
          In Optional[Union[Any, List[Tuple[Any, Any]], bool, bytes]]
        File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 147, in _hostsettings:
            No attribute 'append' on bool [attribute-error]
          In Optional[Union[Any, List[Tuple[Any, Any]], bool, bytes]]
        File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 147, in _hostsettings:
            No attribute 'append' on bytes [attribute-error]
          In Optional[Union[Any, List[Tuple[Any, Any]], bool, bytes]]
      
      Differential Revision: https://phab.mercurial-scm.org/D11931
      08af0adc
    • Matt Harbison's avatar
      pytype: stop excluding wireprotoserver.py · 81805bba
      Matt Harbison authored
      The `config` entry is a 2 part tuple, which has `__iter__()`:
      
        File "/mnt/c/Users/Matt/hg/mercurial/wireprotoserver.py", line 253, in _availableapis:
            No attribute '__iter__' on Callable[[Any, Any], Any] [attribute-error]
          In Union[Callable[[Any, Any, Any, Any, Any], None], Callable[[Any, Any], Any]]
        File "/mnt/c/Users/Matt/hg/mercurial/wireprotoserver.py", line 253, in _availableapis:
            No attribute '__iter__' on Callable[[Any, Any, Any, Any, Any], None] [attribute-error]
          In Union[Callable[[Any, Any, Any, Any, Any], None], Callable[[Any, Any], Any]]
      
      Differential Revision: https://phab.mercurial-scm.org/D11930
      81805bba
  4. Dec 14, 2021
    • Matt Harbison's avatar
      pytype: stop excluding pycompat.py · 12a43f85
      Matt Harbison authored
      Whatever issues were here seem to have been previously fixed.
      
      Differential Revision: https://phab.mercurial-scm.org/D11929
      12a43f85
    • Matt Harbison's avatar
      procutil: avoid an uninitialized variable usage on tempfile exception · f8540fe4
      Matt Harbison authored
      If `pycompat.unnamedtempfile()` raises an exception, it would have called
      `stdin.close()` in the `finally` block without it being initialized first.
      
      Differential Revision: https://phab.mercurial-scm.org/D11928
      f8540fe4
    • Matt Harbison's avatar
      pytype: stop excluding procutil.py · 333a2656
      Matt Harbison authored
      This avoids these false warnings:
      
        File "/mnt/c/Users/Matt/hg/mercurial/utils/procutil.py", line 78, in <module>:
            No attribute 'register' on Type[io.BufferedIOBase] [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/utils/procutil.py", line 117, in <module>:
            No attribute 'register' on Type[io.IOBase] [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/utils/procutil.py", line 770, in runbgcommandpy3:
            No attribute 'close' on int [attribute-error]
          In Union[IO[Union[bytes, str]], int]
      
      Differential Revision: https://phab.mercurial-scm.org/D11927
      333a2656
    • Matt Harbison's avatar
      pytype: stop excluding chgserver.py · 7caaefa4
      Matt Harbison authored
      This teaches pytype about some lazy initialization, and avoids the following:
      
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 666, in _checkextensions:
            No attribute '_hashstate' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 672, in _checkextensions:
            No attribute '_hashstate' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 677, in _bind:
            No attribute '_realaddress' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 683, in _bind:
            No attribute '_realaddress' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 686, in _createsymlink:
            No attribute '_baseaddress' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 686, in _createsymlink:
            No attribute '_realaddress' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 688, in _createsymlink:
            No attribute '_baseaddress' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 689, in _createsymlink:
            No attribute '_realaddress' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 690, in _createsymlink:
            No attribute '_baseaddress' on chgunixservicehandler [attribute-error]
      
      Differential Revision: https://phab.mercurial-scm.org/D11926
      7caaefa4
    • Matt Harbison's avatar
      pytype: stop excluding webcommands.py · ea13dabb
      Matt Harbison authored
      I have no idea why, but asserting that each value added to `emptydirs` is not
      None didn't fix this:
      
        File "/mnt/c/Users/Matt/hg/mercurial/hgweb/webcommands.py", line 621, in dirlist:
            Function bytes.join was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, iterable: Iterable[bytes])
          Actually passed: (self, iterable: List[None])
      
      Differential Revision: https://phab.mercurial-scm.org/D11924
      ea13dabb
    • Matt Harbison's avatar
    • Matt Harbison's avatar
      pytype: stop excluding patch.py · 290f9c15
      Matt Harbison authored
      The underlying `email.generator.BytesGenerator` is documented as requiring an
      `fp` that accepts bytes, so I'm not sure why pytype is getting confused:
      
        File "/mnt/c/Users/Matt/hg/mercurial/patch.py", line 112, in msgfp:
            Function Generator.__init__ was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, outfp: TextIO, ...)
          Actually passed: (self, outfp: io.BytesIO, ...)
      
      Differential Revision: https://phab.mercurial-scm.org/D11922
      290f9c15
    • Matt Harbison's avatar
      pytype: stop excluding statprof.py · d2fff292
      Matt Harbison authored
      This seems to have worked fine before (at least on Linux).  We could just add
      suppression comments, but this file already imports from the mercurial package,
      which seems to prevent this from running as a standalone program because of the
      relative import of `pycompat`.  PyCharm isn't happy either way.
      
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 501, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 1091, in main
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 501, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 431, in profile
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 522, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 1091, in main
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 522, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 431, in profile
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 523, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 1091, in main
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 523, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 431, in profile
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 524, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 1091, in main
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 524, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 431, in profile
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 796, in _write:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
      
      Differential Revision: https://phab.mercurial-scm.org/D11921
      d2fff292
  5. Dec 13, 2021
  6. Dec 14, 2021
  7. Dec 13, 2021
  8. Dec 07, 2021
  9. Dec 08, 2021
  10. Dec 07, 2021
  11. Nov 07, 2021
  12. Dec 07, 2021
  13. Dec 10, 2021
    • Simon Sapin's avatar
      tests: add a short `sleep` in test-status.t · 04d756b7
      Simon Sapin authored
      With dirstate-v2 and rhg both enabled, this test would sometimes fail for me
      with:
      
      ```
      --- tests/test-status.t
      +++ tests/test-status.t#dirstate-v2.err
      @@ -943,7 +943,7 @@
         $ rm subdir/unknown
         $ hg status
         $ hg debugdirstate --all --no-dates | grep '^ '
      -      0         -1 set                 subdir
      +      0         -1 unset               subdir
      ```
      
      Meaning that `status` did not write a directory mtime in the dirstate
      as expected. This can happen if the observed mtime of the directory is
      the same as "current time" at the start of `status`. This current time
      is obtained by creating a temporary file and checking its mtime.
      
      Even with ext4 on my system being able to store nanosecond precision,
      identical mtime for successive but separate operations is still possible
      becuse the kernel may cache the current time:
      https://stackoverflow.com/a/14393315/1162888
      
      0.1 second should be enough for this cache to be updated, without
      significantly slowing down the test.
      
      Differential Revision: https://phab.mercurial-scm.org/D11900
      04d756b7
    • Simon Sapin's avatar
      rhg: Add support for `rhg status --copies` · 473af5cb
      Simon Sapin authored
      Copy sources are collected during `status()` rather than after the fact like
      in Python, because `status()` takes a `&mut` exclusive reference to the dirstate map
      (in order to potentially mutate it for directory mtimes) and returns `Cow<'_, HgPath>`
      that borrow the dirstate map.
      
      Even though with `Cow` only some shared borrows remain, the still extend the same
      lifetime of the initial `&mut` so the dirstate map cannot be borrowed again
      to access copy sources after the fact:
      
      https://doc.rust-lang.org/nomicon/lifetime-mismatch.html#limits-of-lifetimes
      
      Additionally, collecting copy sources during the dirstate tree traversal that
      `status()` already does avoids the cost of another traversal or other lookups
      (though I haven’t benchmarked that cost).
      
      Differential Revision: https://phab.mercurial-scm.org/D11899
      473af5cb
Loading