author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
Wed, 24 Aug 2022 16:38:13 +0100 | |
changeset 49465 | b07465adbcc8 |
parent 48083 | bf8837e3d7ce |
child 50003 | e98fd81bb151 |
permissions | -rw-r--r-- |
42764
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Raphaël Gomès <rgomes@octobus.net>
parents:
42609
diff
changeset
|
1 |
// dirstate module |
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Raphaël Gomès <rgomes@octobus.net>
parents:
42609
diff
changeset
|
2 |
// |
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Raphaël Gomès <rgomes@octobus.net>
parents:
42609
diff
changeset
|
3 |
// Copyright 2019 Raphaël Gomès <rgomes@octobus.net> |
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Raphaël Gomès <rgomes@octobus.net>
parents:
42609
diff
changeset
|
4 |
// |
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Raphaël Gomès <rgomes@octobus.net>
parents:
42609
diff
changeset
|
5 |
// This software may be used and distributed according to the terms of the |
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Raphaël Gomès <rgomes@octobus.net>
parents:
42609
diff
changeset
|
6 |
// GNU General Public License version 2 or any later version. |
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Raphaël Gomès <rgomes@octobus.net>
parents:
42609
diff
changeset
|
7 |
|
47343
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47340
diff
changeset
|
8 |
use crate::dirstate_tree::on_disk::DirstateV2ParseError; |
47380
bd88b6bfd8da
rhg: Add support for dirstate-v2
Simon Sapin <simon.sapin@octobus.net>
parents:
47343
diff
changeset
|
9 |
use crate::revlog::node::NULL_NODE; |
46634
98a455a62699
rust: Make `DirstateParents`’s fields typed `Node`s
Simon Sapin <simon.sapin@octobus.net>
parents:
46633
diff
changeset
|
10 |
use crate::revlog::Node; |
48083
bf8837e3d7ce
dirstate: Remove the flat Rust DirstateMap implementation
Simon Sapin <simon.sapin@octobus.net>
parents:
48040
diff
changeset
|
11 |
use crate::utils::hg_path::HgPath; |
48040
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
12 |
use bytes_cast::BytesCast; |
42764
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Raphaël Gomès <rgomes@octobus.net>
parents:
42609
diff
changeset
|
13 |
|
42543
2dcee6497b0b
rust-dirstate: add "dirs" Rust implementation
Raphaël Gomès <rgomes@octobus.net>
parents:
42440
diff
changeset
|
14 |
pub mod dirs_multiset; |
48040
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
15 |
pub mod entry; |
42440
d3b5cbe311d9
rust-dirstate: create dirstate submodule
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
16 |
pub mod parsers; |
43271
99394e6c5d12
rust-dirstate-status: add first Rust implementation of `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents:
42960
diff
changeset
|
17 |
pub mod status; |
42440
d3b5cbe311d9
rust-dirstate: create dirstate submodule
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
18 |
|
48040
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
19 |
pub use self::entry::*; |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
20 |
|
47984
81aedf1fc897
rust: Add Repo::dirstate_map and use it in `rhg status`
Simon Sapin <simon.sapin@octobus.net>
parents:
47683
diff
changeset
|
21 |
#[derive(Debug, PartialEq, Copy, Clone, BytesCast)] |
46633
f88e8ae0aa8f
rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents:
46508
diff
changeset
|
22 |
#[repr(C)] |
42764
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Raphaël Gomès <rgomes@octobus.net>
parents:
42609
diff
changeset
|
23 |
pub struct DirstateParents { |
46634
98a455a62699
rust: Make `DirstateParents`’s fields typed `Node`s
Simon Sapin <simon.sapin@octobus.net>
parents:
46633
diff
changeset
|
24 |
pub p1: Node, |
98a455a62699
rust: Make `DirstateParents`’s fields typed `Node`s
Simon Sapin <simon.sapin@octobus.net>
parents:
46633
diff
changeset
|
25 |
pub p2: Node, |
42440
d3b5cbe311d9
rust-dirstate: create dirstate submodule
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
26 |
} |
d3b5cbe311d9
rust-dirstate: create dirstate submodule
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
27 |
|
47380
bd88b6bfd8da
rhg: Add support for dirstate-v2
Simon Sapin <simon.sapin@octobus.net>
parents:
47343
diff
changeset
|
28 |
impl DirstateParents { |
bd88b6bfd8da
rhg: Add support for dirstate-v2
Simon Sapin <simon.sapin@octobus.net>
parents:
47343
diff
changeset
|
29 |
pub const NULL: Self = Self { |
bd88b6bfd8da
rhg: Add support for dirstate-v2
Simon Sapin <simon.sapin@octobus.net>
parents:
47343
diff
changeset
|
30 |
p1: NULL_NODE, |
bd88b6bfd8da
rhg: Add support for dirstate-v2
Simon Sapin <simon.sapin@octobus.net>
parents:
47343
diff
changeset
|
31 |
p2: NULL_NODE, |
bd88b6bfd8da
rhg: Add support for dirstate-v2
Simon Sapin <simon.sapin@octobus.net>
parents:
47343
diff
changeset
|
32 |
}; |
49465
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48083
diff
changeset
|
33 |
|
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48083
diff
changeset
|
34 |
pub fn is_merge(&self) -> bool { |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48083
diff
changeset
|
35 |
return !(self.p2 == NULL_NODE); |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48083
diff
changeset
|
36 |
} |
47380
bd88b6bfd8da
rhg: Add support for dirstate-v2
Simon Sapin <simon.sapin@octobus.net>
parents:
47343
diff
changeset
|
37 |
} |
bd88b6bfd8da
rhg: Add support for dirstate-v2
Simon Sapin <simon.sapin@octobus.net>
parents:
47343
diff
changeset
|
38 |
|
47343
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47340
diff
changeset
|
39 |
pub type StateMapIter<'a> = Box< |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47340
diff
changeset
|
40 |
dyn Iterator< |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47340
diff
changeset
|
41 |
Item = Result<(&'a HgPath, DirstateEntry), DirstateV2ParseError>, |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47340
diff
changeset
|
42 |
> + Send |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47340
diff
changeset
|
43 |
+ 'a, |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47340
diff
changeset
|
44 |
>; |
45613
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
45612
diff
changeset
|
45 |
|
47343
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47340
diff
changeset
|
46 |
pub type CopyMapIter<'a> = Box< |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47340
diff
changeset
|
47 |
dyn Iterator<Item = Result<(&'a HgPath, &'a HgPath), DirstateV2ParseError>> |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47340
diff
changeset
|
48 |
+ Send |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47340
diff
changeset
|
49 |
+ 'a, |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47340
diff
changeset
|
50 |
>; |