Mercurial > public > mercurial-scm > hg
annotate rust/hg-cpython/src/dirstate.rs @ 48061:060cd909439f
dirstate: drop all logic around the "non-normal" sets
The dirstate has a lot of code to compute a set of all "non-normal" and
"from_other_parent" entries.
This is all used in one, unique, location, when `setparent` is called and moved
from a merge to a non merge. At that time, any "merge related" information has
to be dropped. This is mostly useful for command like `graft` or `shelve` that
move to a single-parent state -before- the commit. Otherwise the commit will
already have removed all traces of the merge information in the dirstate (e.g.
for a regular merges).
The bookkeeping for these sets is quite invasive. And it seems simpler to just
drop it and do the full computation in the single location where we actually
use it (since we have to do the computation at least once anyway).
This simplify the code a lot, and clarify why this kind of computation is
needed.
The possible drawback compared to the previous code are:
- if the operation happens in a loop, we will end up doing it multiple time,
- the C code to detect entry of interest have been dropped, for now. It will be
re-introduced later, with a processing code directly in C for even faster
operation.
Differential Revision: https://phab.mercurial-scm.org/D11507
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 28 Sep 2021 20:05:37 +0200 |
parents | d5528ac9b4f2 |
children | 269ff8978086 |
rev | line source |
---|---|
42303
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
1 // dirstate.rs |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
2 // |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
3 // Copyright 2019 Raphaël Gomès <rgomes@octobus.net> |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
4 // |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
5 // This software may be used and distributed according to the terms of the |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
6 // GNU General Public License version 2 or any later version. |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
7 |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
8 //! Bindings for the `hg::dirstate` module provided by the |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
9 //! `hg-core` package. |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
10 //! |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
11 //! From Python, this will be seen as `mercurial.rustext.dirstate` |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42749
diff
changeset
|
12 mod copymap; |
42746
b3518b0baa47
rust-dirstate: create dirstate submodule in hg-cpython
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42609
diff
changeset
|
13 mod dirs_multiset; |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42749
diff
changeset
|
14 mod dirstate_map; |
48043
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48025
diff
changeset
|
15 mod item; |
43273
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
16 mod status; |
48043
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48025
diff
changeset
|
17 use self::item::DirstateItem; |
44529
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
18 use crate::{ |
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
19 dirstate::{ |
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
20 dirs_multiset::Dirs, dirstate_map::DirstateMap, status::status_wrapper, |
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
21 }, |
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
22 exceptions, |
43273
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
23 }; |
48044
d5528ac9b4f2
dirstate: Use the Rust implementation of DirstateItem when Rust is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
24 use cpython::{PyBytes, PyDict, PyList, PyModule, PyObject, PyResult, Python}; |
47280
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47123
diff
changeset
|
25 use hg::dirstate_tree::on_disk::V2_FORMAT_MARKER; |
47567
7a15dea6d303
dirstate-item: also build DistateItem in dirstate.directories()
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47539
diff
changeset
|
26 |
42303
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
27 /// Create the module, with `__package__` given from parent |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
28 pub fn init_module(py: Python, package: &str) -> PyResult<PyModule> { |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
29 let dotted_name = &format!("{}.dirstate", package); |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
30 let m = PyModule::new(py, dotted_name)?; |
42537
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42408
diff
changeset
|
31 |
45517
2a68a5ec8dd0
rust-cpython: switch logging facade from `simple_logger` to `env_logger`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44839
diff
changeset
|
32 env_logger::init(); |
44540
82f51ab7a2dd
rust: add logging utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44529
diff
changeset
|
33 |
42303
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
34 m.add(py, "__package__", package)?; |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
35 m.add(py, "__doc__", "Dirstate - Rust implementation")?; |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
36 |
44529
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
37 m.add( |
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
38 py, |
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
39 "FallbackError", |
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
40 py.get_type::<exceptions::FallbackError>(), |
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
41 )?; |
42537
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42408
diff
changeset
|
42 m.add_class::<Dirs>(py)?; |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42749
diff
changeset
|
43 m.add_class::<DirstateMap>(py)?; |
48043
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48025
diff
changeset
|
44 m.add_class::<DirstateItem>(py)?; |
47280
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47123
diff
changeset
|
45 m.add(py, "V2_FORMAT_MARKER", PyBytes::new(py, V2_FORMAT_MARKER))?; |
43273
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
46 m.add( |
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
47 py, |
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
48 "status", |
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
49 py_fn!( |
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
50 py, |
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
51 status_wrapper( |
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
52 dmap: DirstateMap, |
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
53 root_dir: PyObject, |
43916
6a88ced33c40
rust-dirstate-status: update bridge for new rust version of `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43456
diff
changeset
|
54 matcher: PyObject, |
44529
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
55 ignorefiles: PyList, |
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
56 check_exec: bool, |
43273
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
57 last_normal_time: i64, |
44529
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
58 list_clean: bool, |
f96b28aa4b79
rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44297
diff
changeset
|
59 list_ignored: bool, |
44839
01afda7e7d6c
rust-hg-cpython: update status bridge with the new `traversedir` support
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44540
diff
changeset
|
60 list_unknown: bool, |
01afda7e7d6c
rust-hg-cpython: update status bridge with the new `traversedir` support
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44540
diff
changeset
|
61 collect_traversed_dirs: bool |
43273
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
62 ) |
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
63 ), |
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43213
diff
changeset
|
64 )?; |
42537
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42408
diff
changeset
|
65 |
42303
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
66 let sys = PyModule::import(py, "sys")?; |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
67 let sys_modules: PyDict = sys.get(py, "modules")?.extract(py)?; |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
68 sys_modules.set_item(py, dotted_name, &m)?; |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
69 |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
70 Ok(m) |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
71 } |