- Sep 01, 2019
-
-
Raphaël Gomès authored
Differential Revision: https://phab.mercurial-scm.org/D6774
-
Raphaël Gomès authored
This change is a direct consequence of this discussion on the mailing list: https://www.mercurial-scm.org/pipermail/mercurial-devel/2019-August/133574.html The implementations of `HgPath` and `HgPathBuf` are, for the most part, taken directly from `OsStr` and `OsString` respectively from the standard library. What this change does *not* yet do is implement the Windows MBCS to WTF8 conversion, but it lays the basis for a very flexible interface for paths. Differential Revision: https://phab.mercurial-scm.org/D6773
-
- Sep 15, 2019
-
-
Yuya Nishihara authored
If decrease_leak_count() were called unnecessarily, there must be a serious bug. It's better to not silently ignore such cases.
-
- Sep 08, 2019
-
-
Yuya Nishihara authored
-
Yuya Nishihara authored
It's the implementation detail of the py_shared_iterator that the leaked reference is kept in Option<_> so that it can be dropped early.
-
Yuya Nishihara authored
It's a public interface now.
-
Yuya Nishihara authored
See the previous commit for why. The docstring is moved accordingly.
-
Yuya Nishihara authored
We wouldn't care the cost of the dynamic dispatch, but I feel a concrete type helps understanding error messages.
-
Yuya Nishihara authored
They will be used in the declaration of Python iterator types.
-
Yuya Nishihara authored
This allows us to put a returned iterator in a struct. We could implement DirsMultisetIter(hash_map::Keys<..>) struct to hide the implementation detail, but I think type alias is good enough for us.
-
- Aug 26, 2019
-
-
sliquister authored
Differential Revision: https://phab.mercurial-scm.org/D6765
-
sliquister authored
For legibility of the resulting regexes, although it may help with performance as well. Differential Revision: https://phab.mercurial-scm.org/D6764
-
sliquister authored
Differential Revision: https://phab.mercurial-scm.org/D6766
-
- Sep 01, 2019
-
-
Yuya Nishihara authored
It wasn't trivial to fix leak_immutable() to be safe since we have to allow immutable operations (e.g. iter()) on the leaked reference. So let's mark it unsafe for now. Callers must take care of the returned object to guarantee the memory safety. I'll revisit this later. I think $leaked<T: 'static> could have a function that converts itself into $leaked<U: 'static> with a given FnOnce(&T) -> &U, where T is $inner_struct, and U is $iterator_type for example.
-
Yuya Nishihara authored
Still leak_immutable() is unsafe since leak_handle must live longer than the leaked_ref.
-
Yuya Nishihara authored
This should catch invalid borrow_mut() calls. Still the ref-sharing interface is unsafe.
-
Yuya Nishihara authored
Since self.inner is managed by PySharedState, it must not be borrowed mutably through the RefCell interface. Otherwise, the underlying object could be mutated while a reference is leaked to Python world.
-
- Aug 31, 2019
-
-
Yuya Nishihara authored
My cargo fmt updated these lines and they look good.
-
- Aug 22, 2019
-
-
Raphaël Gomès authored
While we still don't handle filenames properly cross-platform, this at least sticks closer to the Python behavior. Differential Revision: https://phab.mercurial-scm.org/D6756
-
- Aug 28, 2019
-
-
sliquister authored
Differential Revision: https://phab.mercurial-scm.org/D6770
-
- Aug 29, 2019
-
-
Raphaël Gomès authored
-
- Aug 17, 2019
-
-
Yuya Nishihara authored
It's no longer possible.
-
Yuya Nishihara authored
Since skip_state only applies to dirstate, it doesn't make sense to unify these constructors and dispatch by enum.
-
Yuya Nishihara authored
I think pass-by-ref is preferred in general.
-
Yuya Nishihara authored
It uses match syntax since map_err() failed to deduce the argument type.
-
Yuya Nishihara authored
Since our rust module depends on TryInto, there's no point to avoid using it. While rewriting copy_into_array(), I noticed CPython interface doesn't check the length of the p1/p2 values, which is marked as TODO.
-
Yuya Nishihara authored
-
Yuya Nishihara authored
-
Yuya Nishihara authored
-
Yuya Nishihara authored
-
Yuya Nishihara authored
At 7cae6bc29ff9, .to_owned() was rewritten as .to_owned().to_vec(), which is no longer needed since the filename is a single reference.
-
Yuya Nishihara authored
Broken at 7cae6bc29ff9.
-
- Aug 16, 2019
-
-
Yuya Nishihara authored
This looks slightly nicer.
-
Yuya Nishihara authored
-
- Jul 10, 2019
-
-
Raphaël Gomès authored
This change also showcases the limitations of the `py_shared_ref!` macro. See the previous commit 'rust-dirstate: rust implementation of dirstatemap` for an explanation for the TODOs in the code. Differential Revision: https://phab.mercurial-scm.org/D6633
-
Raphaël Gomès authored
The `dirstatemap` is one of the last building blocks needed to get to a `dirstate.walk` Rust implementation. Disclaimer: This change is part of a big (10) series of patches, all of which started as one big changeset that took a long time to write. This `dirstatemap` implementation is a compromise in terms of complexity both for me and for the reviewers. I chose to submit this patch right now because while it is not perfect, it works and is simple enough (IMHO) to be reviewed. The Python implementation uses a lot of lazy propertycaches, breaks encapsulation and is used as an iterator in a lot of places, all of which dictated the somewhat unidiomatic patterns in this change. Like written in the comments, rewriting this struct to use the typestate pattern might be a good idea, but this is a good first step. Differential Revision: https://phab.mercurial-scm.org/D6632
-
- Jul 09, 2019
-
-
Raphaël Gomès authored
Following an experiment done by Georges Racinet, we now have a working way of sharing references between Python and Rust. This is needed in many points of the codebase, for example every time we need to expose an iterator to a Rust-backed Python class. In a few words, references are (unsafely) marked as `'static` and coupled with manual reference counting; we are doing manual borrow-checking. This changes introduces two declarative macro to help reduce boilerplate. While it is better than not using macros, they are not perfect. They need to: - Integrate with the garbage collector for container types (not needed as of yet), as stated in the docstring - Allow for leaking multiple attributes at the same time - Inject the `py_shared_state` data attribute in `py_class`-generated structs - Automatically namespace the functions and attributes they generate For at least the last two points, we will need to write a procedural macro instead of a declarative one. While this reference-sharing mechanism is being ironed out I thought it best not to implement it yet. Lastly, and implementation detail renders our Rust-backed Python iterators too strict to be proper drop-in replacements, as will be illustrated in a future patch: if the data structure referenced by a non-depleted iterator is mutated, an `AlreadyBorrowed` exception is raised, whereas Python would allow it, only to raise a `RuntimeError` if `next` is called on said iterator. This will have to be addressed at some point. Differential Revision: https://phab.mercurial-scm.org/D6631
-
Raphaël Gomès authored
Differential Revision: https://phab.mercurial-scm.org/D6630
-
- Jul 17, 2019
-
-
Raphaël Gomès authored
- Use opaque `Iterator` type instead of implementation-specific one from `HashMap` - Make `DirsMultiset` behave like a set both in Rust and from Python Differential Revision: https://phab.mercurial-scm.org/D6690
-
- Jul 09, 2019
-
-
Raphaël Gomès authored
This improves code readability quite a bit, while also adding a layer of safety because we're checking the state byte against the enum. Differential Revision: https://phab.mercurial-scm.org/D6629
-