Skip to content
Snippets Groups Projects
  1. Jan 05, 2025
  2. Jan 03, 2025
    • Matt Harbison's avatar
      xxx-windows: try replacing stdio streams in one place · 4836cc47891d
      Matt Harbison authored
      This doesn't work because dispatch.py imports procutil, which does its setup of
      stdio outside of any function.  That means replacing stdio here results in it
      not being at the closest to the OS (the procutil stuff is), and output is lost
      when the pager is spun up (but again not when explicitly piped to the pager).
      Womp womp.  Maybe we can move this code to procutil (it already calls something
      in the windows module to wrap stdout/stderr), but it would have to be done
      first, prior to all of the other wrapping.  Note there is a comment in there
      around line 162 about maybe needing a silly unicode wrapper if `.buffer` doesn't
      exist... that seems to be what this is.
      
      The comment in here is probably still useful, and I wonder if the `encoding` arg
      should be based on the `encoding.encoding` value instead of a hardcoded 'mbcs'.
      Ditto the `errors` being based on `encoding.encodingmode`, so that `HGENCODING`
      and `HGENCODINGMODE` respectively are honored.  Otherwise, this is a lesson in
      what not to do.
      4836cc47891d
    • Matt Harbison's avatar
      xxx-windows: avoid replacing `sys.__std{in,out,err}__` · 28a061aee52d
      Matt Harbison authored
      PyCharm was yapping that these are final, but when I commented them out, I got
      a very early crash related to checking isatty() on a closed file descriptor.
      This fixes that, though I suspect it would be even simpler to do the replacement
      in the windows module.  On the one hand, we do want this setup very early in the
      process.  OTOH, the pager isn't configured until after stdio is customized.  And
      if there is some error output that happens before that, writing bytes without
      the pager and without enabling legacy stdio seems to work.
      
      Aside: I wonder why we have custom line buffering classes in procutil if there's
      line buffering setup on stdio in dispatch, just below this.  A python2 holdover
      maybe?
      28a061aee52d
  3. Jan 05, 2025
    • Matt Harbison's avatar
      windows: really stop using legacy stdio during test runs · 7905b7bc4b21
      Matt Harbison authored
      I realized that the test runner also sets this, because a lot of the test
      modules also do stdio in bytes, so setting this in the runner fixed a lot of
      failures.  We'll have to port whatever fix is made to hg itself to all of the
      needed places in the test modules (and we can make this smarter by only
      conditionally clearing it if a couple of test variables are also set), but for
      now, keep it simple.
      7905b7bc4b21
  4. Jan 03, 2025
    • Matt Harbison's avatar
      windows: stop enabling legacy stdio by default in the `hg` executable · c3edf68bea75
      Matt Harbison authored
      We need to stop doing this in order to exercize the new code in the previous
      commit.  The environment variable can still be manually set to revert to the
      previous state of things that has been used since py3 support was added, for
      now.  We should try to get away from it entirely though, because this problem
      affects more than what is written up in issue6952.[1]
      
      I've tested locally with the `hg.exe` form of this, and the tests pass.  That
      gives me some hope, but 1) the pager wouldn't typically be used in tests due to
      the runner capturing the output, unless a pager is explicitly requested (like a
      few tests do), and 2) the tests are basically all ascii characters anyway, so
      that's kind of hard to screw up.  (The test runner sets `HGENCODING=ascii`, I
      assume for portability, so that's unlikely to change.  I've also managed to
      generate corrupt file names when trying to write a test for an issue with
      non-ascii file names[2], using code that works perfectly fine outside the test
      runner.  But we do seem to be getting the output that was previously missing,
      and the project CI system will cover `hg.bat` when it tests the wheels.)
      
      [1] mercurial/tortoisehg/thg#5854
      [2] mercurial/tortoisehg/thg#5923
      c3edf68bea75
    • Pierre Augier's avatar
      windows: effect of PYTHONLEGACYWINDOWSSTDIO when not defined · 40c956a683a4
      Pierre Augier authored
      Fix issue6952.
      40c956a683a4
  5. Jan 07, 2025
  6. Jan 31, 2025
    • Arseniy Alekseyev's avatar
      rhg: buffer the output of `rhg status` · 65839176cea9
      Arseniy Alekseyev authored
      Before this commit, `hg status` was issuing multiple `write` syscalls per
      line printed, separately writing out the path and the status fragments.
      
      This change makes hg status on large number of files significantly faster,
      going from 1.8s to 1.2s in one case.
      
      This requires adding the color information to `StdoutBuffer`,
      and moving the formatting functions from ui to it.
      
      I made `StdoutBuffer` generic over the underlying writer,
      without insisting on BufWriter, because I anticipated the need to use
      it with both full-buffered and line-buffered writers.
      That didn't end up being necessary, but I think the code is still better
      this way.
      65839176cea9
  7. Jan 30, 2025
    • Pierre-Yves David's avatar
      clone: explicitly steal lock instead of assigning previous lock · 0f2268783c11
      Pierre-Yves David authored
      The issue with reusing the lock from another repository is that various internal
      state are no longer correct, the main example of that is the dirstate, captured
      in the wlock to make sure it is written (when needed) on lock release. So
      instead, we create a proper lock from the repository, but "stealing" the on-disk
      lock from the previous object.
      
      This is a bit weird, but less than the previous situation.
      0f2268783c11
  8. Dec 20, 2024
  9. Feb 01, 2025
  10. Jan 25, 2025
  11. Jan 24, 2025
  12. Jan 29, 2025
  13. Jan 30, 2025
  14. Jan 27, 2025
  15. Jan 30, 2025
  16. Jan 27, 2025
  17. Jan 29, 2025
  18. Nov 30, 2024
  19. Nov 29, 2024
    • Pierre-Yves David's avatar
      perf: disable progress by default in stream-generate · 492de5c0ecdd
      Pierre-Yves David authored
      Progress can take a signifiant time and that is not what we are measuring it.
      
      This can impact the benchmark result when the command is run in a terminal.
      
      (looking at how much time is consume is now possible, but a quest for another
      day)
      492de5c0ecdd
  20. Nov 28, 2024
  21. Jan 07, 2025
    • Matt Harbison's avatar
      typing: add some type annotations to the `wireprotoframing` module · 068398a8c9cb
      Matt Harbison authored
      `flushcommands()` and a few other generators got a slightly modified return type
      after the pyupgrade series ending with 70a75d379daf.  This fixes those, and grabs
      some other low and mid hanging fruit here.
      
      Note that there are possibly two bugs detected here- in the `inputstream` and
      `outputstream` classes, the `flush()` and `finish()` methods respectively have
      surprising issues.  pytype flagged the latter when the return value was typed,
      but it surprisingly doesn't see the lack of `flush()` on the `Decoder` class.
      I wonder if either of these are the cause of the occasional odd-length string
      error I see in the `hg serve` output from time to time.  In any event, punt
      those changes down the road for now, and mark with a TODO.
      068398a8c9cb
  22. Jan 13, 2025
    • Matt Harbison's avatar
      typing: add type annotations for wireprotoframing encoder/decoder classes · 1a612f9ec2c4
      Matt Harbison authored
      This was low hanging fruit, and will point out an apparent programming bug.
      
      The arguments are left untyped for now, because the internal compressors and
      decompressors generally take a `Buffer` object, and return bytes.  I've had
      issues around using `typing_extensions.Buffer` with pytype in the past, but also
      the identity classes return the argument unmodified, so that will break the type
      annotation.  We'd probably need an instance check, and a cast if it's not bytes.
      
      Having to roll up all of the encoder and decoder types into a union type is a
      bit annoying, but the protocol class can't be used in the map because it then
      assumes that type will be instantiated.  I also couldn't get it to work with a
      `TypeVar` bound to indicate that it's actually a subclass either.  Oh well.
      1a612f9ec2c4
    • Matt Harbison's avatar
      typing: add some type annotations to the `merge.mergeresult` class · f3762eafed66
      Matt Harbison authored
      The generated type annotations around `filemap()` and `files()` were slightly
      modified by the pyupgrade series culminating in 70a75d379daf.  This module is
      way more complicated than the other changes, but these weren't too bad to figure
      out.
      
      The typing caught a trivial issue in `sparse`- it was passing an empty data list
      to `addfile()` for the `ACTION_REMOVE` case, instead of a tuple or None.
      `merge.manifestmerge()` calls this function with None for the data, so 1) it has
      to be typed as optional, and 2) is safe to pass None in the sparse code.
      f3762eafed66
    • Matt Harbison's avatar
      streamclone: unbyteify string args to builtin Error classes · 10e7adbffa8c
      Matt Harbison authored
      This avoids printing the error with a `b''` prefix in the case of `ValueError`.
      The custom `ProgrammingError` class is special in that it won't do that, and can
      take either bytes or str.  But there's no point in passing bytes when it is just
      going to decode to str at runtime anyway.
      10e7adbffa8c
    • Matt Harbison's avatar
      typing: add trivial type annotations to `mercurial/streamclone.py` · f5471af96a52
      Matt Harbison authored
      These are the easy/obvious/documented ones.  We'll leave the harder ones for
      later.
      f5471af96a52
    • Matt Harbison's avatar
      cborutil: unbyteify string args to builtin Error classes · 8a2091a2f974
      Matt Harbison authored
      This avoids printing the error with a `b''` prefix.  The `CBORDecodeError` class
      subclasses `Exception`, not one of the usual error classes in `mercurial.error`.
      8a2091a2f974
    • Matt Harbison's avatar
      typing: add type annotations to most of `mercurial/utils/cborutil.py` · 5e09c6b5b795
      Matt Harbison authored
      These are the easy/obvious/documented ones.  We'll leave the harder ones for
      later.
      5e09c6b5b795
    • Matt Harbison's avatar
      typing: lock in the type annotations that were lost with the pyupgrade changes · 45dc0f874b8c
      Matt Harbison authored
      For some reason, these reverted from a specific type to something less useful
      after the changes that culminated in 70a75d379daf.  (e.g. the `remotefilectx`
      method went from `Generator[remotefilectx, Any, None]` to
      `Generator[nothing, Any, None]`.)  The previous typing for `merge.filemap` was
      `Generator[Tuple[Any, Tuple[Any, Any, Any]], Any, None]`, and decayed to
      `Generator[nothing, Any, None]`.  I don't feel like unravelling the specific
      types here, so restore the equivalent of that.
      45dc0f874b8c
  23. Jan 07, 2025
  24. Jan 15, 2025
Loading