Skip to content
Snippets Groups Projects
  1. Mar 14, 2025
    • Mitchell Kember's avatar
      rust-annotate: allow --follow · 40bf6deb
      Mitchell Kember authored
      This makes rhg annotate support --follow as an alias for --file. It has been
      marked deprecated since 2010 (f142fa3c0a8c).
      However, Emacs vc-annotate still passes it, and we don't want it to fall back.
      40bf6deb
  2. Mar 20, 2025
    • Mitchell Kember's avatar
      rust-annotate: support --rev wdir() · f7d3c6cb
      Mitchell Kember authored
      This adds support for annotating a file in wdir(). Lines that are changed in the
      working directory get annotated with dirstate.p1 followed by "+", as in Python.
      
      I had to change some test-annotate.t output for an edge case. If file "foo" does
      not exist, `hg annotate -r wdir() foo` prints a slightly different error message
      depending on whether "foo" was ever previously tracked. I don't think this is
      useful or done purposefully, so it doesn't seem worth complicating rhg annotate
      to behave in the same way.
      f7d3c6cb
  3. Feb 18, 2025
  4. Feb 19, 2025
    • Mitchell Kember's avatar
      rust-revset: support resolving wdir() · f7693a8a
      Mitchell Kember authored
      This makes revset::resolve_single return RevisionOrWdir. Previously, it returned
      RevlogError::WDirUnsupported (leading to abort, not fallback) for 2147483647 and
      ffffffffffffffffffffffffffffffffffffffff. It did not recognize 'wdir()' itself,
      so that would lead to Python fallback. Now, it treats all 3 cases the same: it
      returns RevisionOrWdir::wdir() and lets the caller decide what to do.
      
      I changed rhg cat, files, and annotate to return HgError::unsupported in this
      case, since wdir is valid. I made `rhg status --change wdir()` behave the same
      as `rhg status`, conforming to the test in test-status.t.
      f7693a8a
  5. Feb 25, 2025
  6. Mar 04, 2025
  7. Feb 26, 2025
  8. Feb 07, 2025
    • Mitchell Kember's avatar
      rhg-annotate: support whitespace options · 874c64e0
      Mitchell Kember authored
      This adds support to rhg annotate for all the whitespace options:
      
          -w, --ignore-all-space
          -b, --ignore-space-change
          -B, --ignore-blank-lines
          -Z, --ignore-space-at-eol
      
      Note that --ignore-blank-lines has no effect on annotate so it is ignored. You
      can see this in dagop.py _annotepair which only checks if blocks are '=' or not,
      whereas the effect of --ignore-blank-lines is to change some '!' into '~'.
      
      When the other 3 are combined, we use the strongest option since -w implies -b
      and -b implies -Z. This is not explicit in the Python implementation, but I have
      verified that's how it behaves.
      874c64e0
  9. Feb 18, 2025
  10. Jan 24, 2025
    • Mitchell Kember's avatar
      rhg: implement rhg annotate · 61839492
      Mitchell Kember authored
      This initial implementation produces the same output as Python for all the files
      I've tried, and is usually 1.5-9x faster. The algorithm is mostly the same, but
      one key difference is that the Rust implementation only converts filelog
      revisions to changelog revisions if they will actually appear in the output.
      
      This does not support all the command line flags yet. In particular, --template,
      --include, --exclude, --skip, and whitespace-related flags will cause fallback
      to Python. Also, --rev 'wdir()' (often used by editor plugins) is not supported.
      There is also no pager.
      61839492
  11. Jan 16, 2025
  12. Feb 05, 2025
    • Mitchell Kember's avatar
      rust: add encoding.rs · bbf1c522
      Mitchell Kember authored
      This is based on encoding.py. It reads the environment variables HGENCODING,
      HGENCODINGMODE, and HGENCODINGAMBIGUOUS. Currently it only supports UTF-8 and
      ascii, but it could be extended to support other local encodings.
      
      Unlike Python, it assumes all internal strings are UTF-8 and does not attempt to
      fallback to latin-1 (or ui.fallbackencoding).
      
      Nothing is using this now, but in the future command output and error messages
      should transition to using it.
      
      I replaced existing calls to `utf8_to_local` and `local_to_uf8` with direct
      String/bytes methods since they were not logically converting between internal
      and local encodings. Instead, they were used (for example) when an error message
      happened to be stored as String but needed to be passed somewhere as bytes. The
      proper fix for this will be to avoid String in the first place.
      bbf1c522
  13. Feb 04, 2025
  14. Jan 31, 2025
    • Arseniy Alekseyev's avatar
      rhg: buffer the output of `rhg status` · 65839176
      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.
      65839176
  15. Jan 28, 2025
  16. Dec 30, 2024
  17. Dec 13, 2024
    • Arseniy Alekseyev's avatar
      rust-hgignore: add a scripting command to print the hgignore regexp · b89c934e
      Arseniy Alekseyev authored
      Add a command `script::hgignore --print-re` to print the
      hgignore regexp.
      
      One complication is that the `rootfilesin`-only matcher doesn't use a
      regular expression, and the existing converts it to something that's
      not a regular expression.
      
      We add code to handle that case.
      
      Since this command is now sufficient to generate a tidy-looking
      regexp for scripting, this frees up the "debug" command to report
      the internal regexp used by the regex engine, so we make that
      change too.
      b89c934e
  18. Dec 16, 2024
    • Mitchell Kember's avatar
      rhg: add resolve_file_args to path_utils.rs · f33f37ac
      Mitchell Kember authored
      Extracted logic for resolving `FILE ...` arguments from cat.rs into a new
      function in path_utils.rs. I plan to use this for rhg annotate.
      
      I tried to reuse hg::utils::files::canonical_path instead, but that didn't work.
      For example it reports a InsideDotHg error for any path containing "..".
      f33f37ac
  19. Dec 13, 2024
    • Arseniy Alekseyev's avatar
      rhg: add a collision detection to complain about duplicated commands · a0587c1b
      Arseniy Alekseyev authored
      The previous commit made it easier (too easy) to define
      commands with identical names. It turns out `clap` does
      nothing to detect such collisions, which also leads to very
      confusing behavior.
      
      This change catches that error, and reports where the commands
      came from.
      a0587c1b
    • Arseniy Alekseyev's avatar
      rhg: consistently use the command name given in clap::command!(<...>) macro · 021c1b16
      Arseniy Alekseyev authored
      Before this patch there are 2 things the user controls:
      
      1. the module/command name, specified in subcommand! macro
      2. the command name, specified in clap::command! macro
      
      If these are out of sync, we get no compile error or a clear runtime
      error, but instead a confusing behavior where command line parser
      parses one thing, but running it doesn't work.
      
      This commit makes the clap::command! macro the sole authority
      determining the command name, so we don't have to worry about
      this weird behavior any more.
      
      It also makes it easy to validate agreement between (1) and (2)
      if we want it, but I didn't add the check because I'm not sure
      people necessarily want it.
      021c1b16
    • Arseniy Alekseyev's avatar
      rhg: simplify the subcommands macro · 92c6c8ab
      Arseniy Alekseyev authored
      Reduce the scope of the macro to only generate individual `SubCommand`
      values. This way, it will be easy to tweak the behavior of
      `add_subcommand_args` and `subcommand_run_fn` without having
      to understand the details of the macro.
      
      It also lets us easy add commands that don't fit the idiom,
      for example the "admin::" commands or "script::" commands.
      92c6c8ab
  20. Dec 03, 2024
  21. Nov 26, 2024
  22. Dec 02, 2024
    • Mitchell Kember's avatar
      rhg: avoid calculating copies for status --no-status · 53dc147b
      Mitchell Kember authored
      This changes how rhg status avoids printing copies with --no-status.
      Originally 668a871454e8 added a check right before printing copies.
      This changes it to match Python and check it earlier by defining
      `list_copies = ... && !no_status`. This makes no difference now, but
      when we implement --rev --rev --copies it will ensure we don't do
      wasteful copy tracing when it's not going to be printed.
      53dc147b
  23. Nov 25, 2024
  24. Nov 04, 2024
Loading