Skip to content
Snippets Groups Projects
  1. Feb 14, 2025
    • Mitchell Kember's avatar
      rust-config: add username parsing · 879029f0
      Mitchell Kember authored
      This adds Config::username which returns HGUSER, ui.username, or EMAIL in that
      order, similar to ui.username() in Python.
      
      I considered following the pattern of EDITOR, VISUAL, PAGER, etc. and using
      add_for_environment_variable, but it's not possible to get the same precendence
      as in Python that way (in particular HGUSER coming after the repo .hg/hgrc), at
      least not without significant changes.
      
      This will be used for 'rhg annotate -r wdir() -u' to annotate the username on
      lines that were changed in the working directory.
      879029f0
  2. Feb 26, 2025
  3. Feb 24, 2025
    • Mitchell Kember's avatar
      rust-annotate: do not impl Sync for Lines · 3ac28aa1
      Mitchell Kember authored
      I failed to notice before that bdiff_diff mutates its inputs by storing
      bookkeeping information in the `n` and `e` fields. This means &Lines can't be
      shared across threads, so Lines cannot be Sync. Fortunately nothing was using
      this. The parallel file reading and line splitting only relies on Send.
      
      The reason I didn't notice this to begin with was that Lines contains a
      *mut ffi::bdiffline, which is accessible from &Lines, so I never wrote or
      thought about &mut Lines. This pattern (using a mutable pointer stored in an
      immutable struct) would be expressed with RefCell if this was pure safe Rust.
      3ac28aa1
  4. Feb 25, 2025
  5. Feb 21, 2025
  6. Feb 18, 2025
  7. 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
  8. Feb 18, 2025
  9. 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
  10. Feb 06, 2025
    • Georges Racinet's avatar
      rust-pyo3-dirstate: status · 38e16da7
      Georges Racinet authored
      This finally makes use of the latest `path` utilities.
      As a side note, `paths_py_list` cannot use `PyHgPathRef` itself
      because by calling `as_ref()` it would make the compiler believe
      it returns code owner by the inner `map` closure.
      Also, `status_path_py_list(py, &status_res.modified)?` can
      probably be replaced by
      
      ```
      PyList::new(status_res.modified.iter().map(|p| PyHgPathRef(p)))?
      ```
      
      with (granted) little benefit, but it could spare us a new utility
      each time there is a new collection type to return.
      38e16da7
  11. Feb 05, 2025
  12. Feb 04, 2025
    • Georges Racinet's avatar
    • Georges Racinet's avatar
      rust-pyo3-dirstate: CopyMap iterators · c917656a
      Georges Racinet authored
      This requires yet another `Sync` marker in `hg-core`.
      
      Of course we are leveraging the new `py_shared_iterator!` for this.
      c917656a
    • Georges Racinet's avatar
      rust-pyo3-dirstate: CopyMap without proxy methods · 6b38ff46
      Georges Racinet authored
      It turns out that it is fairly easy to call the core `DirstateMap`
      methods from a `CopyMap` PyO3 object, hence we do not need to introduce
      proxy methods on the FFI `DirstateMap` as was done in `rust-cpython`.
      It is more straightforward, and is somewhat easier to make with PyO3
      because we have all these intermediates between the Rust and Python layers
      (`Bound`, `Py<T>`).
      
      From the Python side, a difference with the `hg-cpython` version is that
      `CopyMap` would be instantiable also directly as `CopyMap(dirstate_map)`.
      Reproducing the `from_inner`, with refcount increase the responsibility in the
      `DirstateMap.copymap()` method would have been less natural (as there is
      no need with the separate `from_inner` in PyO3 constructors) and somehow
      we felt it was sounder to force the ref cloning from `CopyMap`.
      6b38ff46
  13. Jan 30, 2025
  14. Feb 05, 2025
  15. Feb 06, 2025
  16. Jan 29, 2025
  17. Feb 04, 2025
    • Georges Racinet's avatar
      rust-pyo3-sharedref: macro to define Python iterators · 8f6d2543
      Georges Racinet authored
      This convenience will help reducing the boilerplate for one of
      the most common use cases of the `pyo3_sharedref` crate.
      
      It is an improved adaptation of a similar macro that was in `hg-cpython`
      (but not in `rust-cpython`). The improvement is that it takes care of
      the constructor, sparing the `share_map` to the caller.
      8f6d2543
  18. Jan 29, 2025
  19. Feb 06, 2025
    • Georges Racinet's avatar
      rust-pyo3: new module for conversions of HgPath and friends · c60f6955
      Georges Racinet authored
      Same as `PyRevision`, the `PyHgPathRef` new-type wrapper is not
      a Python type, but it implements `IntoPyObject`, which will spare
      us tedious uses of `PyBytes::new`.
      
      The `paths_py_list` function is the the analog of `revs_py_list`
      for paths. There was one similar utility in `hg-cpython`, within
      the `dirstate::status` module. We feel it should be in a more global
      location, and have a name consistent with utilities for revisions.
      
      The `paths_pyiter_collect` function is similarly the analog of
      `revs_pyiter_collect`.
      c60f6955
  20. Jan 29, 2025
    • Georges Racinet's avatar
      rust-pyo3-dirsate: DirstateMap definition and constructors · e7b82589
      Georges Racinet authored
      With rust-cpython, using `Option<T>` in the Rust signature would
      translate automatically into a Python keyword argument, leading
      to unpleasantness on the Rust side in some cases (not here, though).
      with PyO3, though the signature can be specified explicitly (positional
      in this case) and there is even a warning that the implicit keywords
      style is deprecated.
      e7b82589
  21. Feb 06, 2025
    • Georges Racinet's avatar
      rust-pyo3: implementing IntoPyObject for Node · e2d2961b
      Georges Racinet authored
      It will be simpler to go through the `PyNode` new-type, than to call
      `PyBytes::new(py, node.as_bytes())`. This also opens up many implicit usages,
      e.g, by `PyList::new` and the various "protocol" methods
      `PyAnyMethods::set_item`.
      
      Also we made the inner `Node` public because we feel `PyNode(n)` to
      be nicer than `n.into::<PyNode>()` as typically a bare `n.into()` will
      not be enough for `into_pyobject()` to know what to do.
      e2d2961b
  22. Jan 29, 2025
    • Georges Racinet's avatar
      rust-pyo3-dirstate: DirstateItem class · 138e4ce2
      Georges Racinet authored
      The rust-cpython version was using `Cell`, which is not `Sync`, hence
      we replace it with the pervasive `RwLock`. This brings in turn some
      minor simplification, as we can access a mutable reference to the inner
      data directly, and do not need the `update()` method (a shortcut to
      perform the `get`/`set` dance of the `Cell`).
      
      Tighter signature control in PyO3 means that `set_fallback_exec` can
      probably be simplified, which we might do once everything is validated
      by the tests.
      138e4ce2
    • Georges Racinet's avatar
      4e5efcaa
    • Georges Racinet's avatar
      c6707e11
    • Georges Racinet's avatar
      rust-pyo3: making PyBytesDeref Sync · 6b3b69b3
      Georges Racinet authored
      This parallels what we have done earlier with the version in rust-cpython.
      It was not needed until now because the previous use of this struct
      was in `InnerRevlog` for the single revision cache, and which is shielded in
      `hg-core` behind a `Mutex`.
      
      But `DirstateMap` is needing its `owner` to be `Sync` more directly.
      In turn it means that maybe we could remove the `Mutex` of `hg-core`.
      6b3b69b3
    • 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
  23. Jan 24, 2025
Loading