|
1 // dirstate module |
|
2 // |
|
3 // Copyright 2019 Raphaël Gomès <rgomes@octobus.net> |
|
4 // |
|
5 // This software may be used and distributed according to the terms of the |
|
6 // GNU General Public License version 2 or any later version. |
|
7 |
|
8 use std::collections::HashMap; |
|
9 |
1 pub mod dirs_multiset; |
10 pub mod dirs_multiset; |
2 pub mod parsers; |
11 pub mod parsers; |
3 |
12 |
4 #[derive(Debug, PartialEq, Copy, Clone)] |
13 #[derive(Debug, PartialEq, Clone)] |
5 pub struct DirstateParents<'a> { |
14 pub struct DirstateParents { |
6 pub p1: &'a [u8], |
15 pub p1: [u8; 20], |
7 pub p2: &'a [u8], |
16 pub p2: [u8; 20], |
8 } |
17 } |
9 |
18 |
10 /// The C implementation uses all signed types. This will be an issue |
19 /// The C implementation uses all signed types. This will be an issue |
11 /// either when 4GB+ source files are commonplace or in 2038, whichever |
20 /// either when 4GB+ source files are commonplace or in 2038, whichever |
12 /// comes first. |
21 /// comes first. |
13 #[derive(Debug, PartialEq)] |
22 #[derive(Debug, PartialEq, Copy, Clone)] |
14 pub struct DirstateEntry { |
23 pub struct DirstateEntry { |
15 pub state: i8, |
24 pub state: i8, |
16 pub mode: i32, |
25 pub mode: i32, |
17 pub mtime: i32, |
26 pub mtime: i32, |
18 pub size: i32, |
27 pub size: i32, |
19 } |
28 } |
20 |
29 |
21 pub type DirstateVec = Vec<(Vec<u8>, DirstateEntry)>; |
30 pub type StateMap = HashMap<Vec<u8>, DirstateEntry>; |
22 |
31 pub type CopyMap = HashMap<Vec<u8>, Vec<u8>>; |
23 #[derive(Debug, PartialEq)] |
|
24 pub struct CopyVecEntry<'a> { |
|
25 pub path: &'a [u8], |
|
26 pub copy_path: &'a [u8], |
|
27 } |
|
28 |
|
29 pub type CopyVec<'a> = Vec<CopyVecEntry<'a>>; |
|
30 |
32 |
31 /// The Python implementation passes either a mapping (dirstate) or a flat |
33 /// The Python implementation passes either a mapping (dirstate) or a flat |
32 /// iterable (manifest) |
34 /// iterable (manifest) |
33 pub enum DirsIterable { |
35 pub enum DirsIterable<'a> { |
34 Dirstate(DirstateVec), |
36 Dirstate(&'a HashMap<Vec<u8>, DirstateEntry>), |
35 Manifest(Vec<Vec<u8>>), |
37 Manifest(&'a Vec<Vec<u8>>), |
36 } |
38 } |