Skip to content
Snippets Groups Projects
  1. Mar 03, 2025
    • Mitchell Kember's avatar
      rust-annotate: support -Tjson · b242980e
      Mitchell Kember authored
      This adds support for the json template in rhg annotate. All other -T/--template
      values continue to fallback to Python.
      
      I matched the format of the Python output so all existing tests pass. This was
      not that hard to do printing JSON manually. The only thing I use serde_json for
      is to escape strings.
      b242980e
  2. Mar 06, 2025
  3. Mar 18, 2025
  4. Mar 04, 2025
  5. Apr 14, 2025
    • Arseniy Alekseyev's avatar
      rhg: extract function expand_aliases · fddb8e12
      Arseniy Alekseyev authored
      In the interest of keeping the code of `main_with_result` clean,
      move all alias-related stuff into a separate function.
      
      Also, add a comment explaining why we think `trailing_args` behavior
      is good enough.
      fddb8e12
  6. Apr 01, 2025
    • Mitchell Kember's avatar
      rhg: support basic aliases · df58357b
      Mitchell Kember authored
      This adds rhg support for resolving aliases. It does not yet support shell
      aliases (starting with "!") or interpolation ("$1", "$@", etc.). It splits words
      in alias definitions using the shlex crate.
      df58357b
  7. Apr 02, 2025
  8. Mar 19, 2025
  9. Mar 20, 2025
    • Arseniy Alekseyev's avatar
      rust-matchers: generalize consumers of the Matcher api somewhat · 4a4c5e65
      Arseniy Alekseyev authored
      In the interest of making it easier to use the matchers API,
      be more generous when producing matchers,
      and be more permissive when consuming them.
      
      - Add the `Send` trait everywhere where we're returning a Boxed matcher,
      so the caller can be free to wrap it into an `Arc` to share between threads.
      
      - For all matcher consumers, accept an &impl instead of a dyn box so
      the caller is free to pass anything they want.
      4a4c5e65
  10. 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
  11. 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
  12. Feb 18, 2025
  13. 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
  14. Feb 25, 2025
  15. Mar 04, 2025
  16. Feb 26, 2025
  17. Feb 21, 2025
    • Mitchell Kember's avatar
      rust: enable workspace lints · 1ef08a03
      Mitchell Kember authored
      This means that lints configured in rust/Cargo.toml will apply to all crates
      within the workspace. Currently there are none but I plan to add some.
      1ef08a03
  18. 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
  19. Feb 18, 2025
  20. 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
  21. Jan 16, 2025
  22. 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
  23. Feb 04, 2025
  24. 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
  25. Jan 28, 2025
  26. Dec 30, 2024
  27. 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
  28. 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
  29. 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
  30. Dec 03, 2024
Loading