Skip to content
Snippets Groups Projects
  1. Feb 21, 2025
  2. 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
  3. Feb 18, 2025
  4. Feb 13, 2025
    • Raphaël Gomès's avatar
      index: remember the generaldelta config instead of getting it from the revlog · 8de68446
      Raphaël Gomès authored
      The code (especially the Rust code) was jumping in 4 dimensions to make sense
      of what was going on because it wrongly assumed that we needed to somehow
      be able to ask a generaldelta index for a non-generaldelta delta chain, which
      doesn't make any sense.
      
      Removing the cargo-culted/vestigial code, this is cleaner and less confusing.
      8de68446
  5. Feb 04, 2025
  6. Jan 29, 2025
    • Georges Racinet's avatar
      rust-pyo3-dirstate: DirstateMap iterators · c5773445
      Georges Racinet authored
      Pretty straightforward with `py_shared_iterator!`.
      c5773445
    • Georges Racinet's avatar
      rust-pyo3-dirstate: making bytes slices in core Sync · d9d6ae9b
      Georges Racinet authored
      For the purposes of providing PyO3 bindings, the data fields that will be
      exposed to Python  have to be `Sync`, hence that is the case of
      `OwningDirstateMap` and its `owner` field.
      
      We had to do something similar for the PyO3 bindings of `revlog`.
      
      In this case, it forces us to adapt the `Deref` wrapper of `PyBytes` used
      in `hg-cpython`, because it must itself now be `Sync` and raw pointers are
      not.
      
      This looks even uglier than it used to, but it does not matter much, because
      our ultimate goal is to remove the rust-cpython bindings altogether.
      d9d6ae9b
  7. Dec 25, 2024
  8. Feb 07, 2025
    • Mitchell Kember's avatar
      rust-ancestors: use BitSet for seen revisions · e9ced84a
      Mitchell Kember authored
      This makes AncestorsIterator store its set of seen revisions in a BitSet-based
      DescendingRevisionSet instead of a HashSet. This provides faster lookups and
      insertions, and uses only A - B bits of memory when iteration goes from revision
      A down to revision B. In the worst case iterating from tip to -1 in the
      mercurial-devel changelog, for example, it would use about 7 KiB.
      
      Running rhg annotate on 200 random files in mercurial-devel gave on average a
      10% improvement. Here is the distribution:
      
       new/old  freq    histogram
      -------- |----- | ---------
          0.81 |   17 | **
          0.84 |   32 | ****
          0.87 |   23 | ***
          0.90 |   24 | ***
          0.92 |   20 | ***
          0.95 |   34 | *****
          0.98 |   18 | **
          1.01 |   24 | ***
          1.04 |    3 |
          1.07 |    5 |
      -------- |----- | ---------
      Avg=0.90 |N=200 |
      e9ced84a
    • Mitchell Kember's avatar
      rust: add GraphError::ParentOutOfOrder · 2fb13c3f
      Mitchell Kember authored
      This will be used in a follow-up commit that creates a data structure optimized
      for inserting revisions in descending order, since it will need to fail if a
      revision number is greater than its descendant (meaning the graph is corrupted).
      2fb13c3f
    • Mitchell Kember's avatar
      rust: refactor conversions from GraphError · 7b4548a0
      Mitchell Kember authored
      This is in preparation for adding a new kind of GraphError.
      7b4548a0
  9. 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
    • Raphaël Gomès's avatar
      rust-inner-revlog: use threadlocals for file handles · 549b58b1
      Raphaël Gomès authored
      In contexts where we access the same revlog from multiple threads
      (like in `annotate`), multiple threads would lock the handle, then read from
      a different place that they would expect, since the `seek` behavior of the
      `InnerRevlog` was written with single threaded access in mind.
      549b58b1
    • Raphaël Gomès's avatar
      rust-inner-revlog: move to `RwLock` instead of `RefCell` · 162f4801
      Raphaël Gomès authored
      We need to make `InnerRevlog` `Sync`, since we want to iterate on and read it
      in parallel. An uncontended `RwLock` has no measurable overhead over a
      `RefCell` in our contexts (to be verified in benchmarks, but I'm pretty sure).
      
      This change assumes that writes/reads to/from the uncompressed chunk cache
      can fail if contended, since it's just a cache, but the rest of operations
      (which are on FileHandles) should wait for the lock and bubble up the panic
      in case of lock poisoning. If a program tries to write from multiple threads
      to a revlog, it had better have good reasons, so I'm not too worried.
      162f4801
    • Raphaël Gomès's avatar
      rust-nodemap: add a `Sync` bound to the buffer type · 198674d8
      Raphaël Gomès authored
      This has always been ok to be `Sync` in all of our contexts, we've just never
      needed to make it explicit. Now that we're starting to do more things in
      parallel, let's add the bound in a new type alias to avoid repetition.
      198674d8
  10. Jan 16, 2025
  11. Jan 14, 2025
  12. Jan 16, 2025
  13. Jan 03, 2025
  14. 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
  15. Dec 18, 2024
    • Mitchell Kember's avatar
      rust: add safe bindings to bdiff.c · 1b7a57a5
      Mitchell Kember authored
      I wrote C FFI bindings manually rather than using a bindgen build step because
      there are only 2 structs and 3 functions and they're not going to change.
      
      Note that the relative path in build.rs means that cargo publish will no longer
      work. If in the future we want to publish to crates.io, we would probably need
      to add a Makefile step that copies bdiff sources into the hg-core crate.
      1b7a57a5
  16. Jan 29, 2025
  17. Jan 28, 2025
  18. Jan 21, 2025
    • Mitchell Kember's avatar
      rust-revlog: fix storage.revlog.mmap.index logic · 8370eb2c
      Mitchell Kember authored
      This ensures that revlogs only use mmap when revlog.mmap.index is true (or
      defaulted to true based on can_populate_mmap()). This config previously had no
      effect because the code in its if-branch was accidentally duplicated below.
      8370eb2c
  19. Jan 14, 2025
    • Mitchell Kember's avatar
      hg-core: fix usage.resources default logic · 72deeea2
      Mitchell Kember authored
      This makes hg-core use ResourceProfileValue::Medium as the default. Before, it
      used ResourceProfileValue::Default (now removed), which was not supposed to be a
      real value, but rather an indirection meaning to use the default (medium).
      
      The motivation for this is that my implementation of rhg annotate was slower on
      some files than Python. This was because Python used the "Medium" profile by
      default (enabling the revlog chunk cache), while Rust used the "Default" profile
      (disabling the revlog chunk cache).
      72deeea2
    • Mitchell Kember's avatar
      hg-core: fix usage.resources typo · 6499af83
      Mitchell Kember authored
      This makes hg-core read resource profile configs from usage.resources. Before,
      it correctly used that for sub-values such as usage.resources.memory, but for
      the generic value it incorrectly used usage.resource (singular).
      6499af83
  20. 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
  21. Dec 06, 2024
    • Arseniy Alekseyev's avatar
      rust-ignore: construct regex Hir object directly, avoiding large regex string · 1866119c
      Arseniy Alekseyev authored
      Rework how we convert patterns to regexes in rust.
      Instead of going patterns -> string -> Regex, which is slow and causes
      some correctness issues, build a structured regex_syntax::hir::Hir value,
      which is faster and it also prevents surprising regex escape.
      
      This change makes the time of `build_regex_match` go from ~70-80ms
      to ~40ms in my testing (for a large hgignore).
      
      The bug I mentioned involves regex patterns that "escape" their
      intended scope. For example, a sequence of hgignore regexp patterns like
      this would previously lead to surprising behavior:
      
          foo(?:
          bar
          baz
          )
      
      this matches foobar and foobaz, and doesn't match bar and baz.
      
      The new behavior is to report a pattern parse error
      The Python hg also has this bug, so this bugfix
      not really helping much, but it's probably better to
      fall back to real Python bugs than to simulate them.
      1866119c
  22. Dec 05, 2024
    • Arseniy Alekseyev's avatar
      rhg: set the expected temp file permissions (0o666 minus umask) · 66e34bc4
      Arseniy Alekseyev authored
      This continues the theme of a48c688d3e80, and fixes the bug #6375,
      which was causing some problems for us, where a non-group-readable
      file can't be copied, which breaks some tools that copy the repo.
      
      This affects both the `checkexec` file and the temporary file we
      use for filesystem time measurement, since either of these files
      remaining on disk can cause this problem, and the 0666 permissions
      are just the better default here.
      66e34bc4
  23. Dec 03, 2024
  24. Dec 02, 2024
  25. Nov 27, 2024
  26. Nov 26, 2024
    • Arseniy Alekseyev's avatar
      rust: implement conversion of RevlogError into HgError · 09a36de5
      Arseniy Alekseyev authored
      The conversion already exists in rhg, where we need to convert
      to CommandError. This commit moves it to hg core.
      
      This makes it easier to code some middleware where we need to carry
      around a type that represents any type of hg error (HgError).
      09a36de5
Loading