author | Simon Sapin <simon.sapin@octobus.net> |
Mon, 12 Apr 2021 18:42:51 +0200 | |
changeset 47105 | ba17a2ee85ac |
parent 47101 | 5d62243c7732 |
child 47108 | e3cebe96c0fc |
permissions | -rw-r--r-- |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
1 |
// dirstate_map.rs |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
2 |
// |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
3 |
// Copyright 2019 Raphaël Gomès <rgomes@octobus.net> |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
4 |
// |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
5 |
// This software may be used and distributed according to the terms of the |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
6 |
// GNU General Public License version 2 or any later version. |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
7 |
|
47105
ba17a2ee85ac
dirstate-tree: Add clear_ambiguous_times in the new DirstateMap
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
8 |
use crate::dirstate::parsers::clear_ambiguous_mtime; |
47101
5d62243c7732
rust: Add a Timestamp struct instead of abusing Duration
Simon Sapin <simon.sapin@octobus.net>
parents:
47093
diff
changeset
|
9 |
use crate::dirstate::parsers::Timestamp; |
46440
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46227
diff
changeset
|
10 |
use crate::errors::HgError; |
46595
98a455a62699
rust: Make `DirstateParents`’s fields typed `Node`s
Simon Sapin <simon.sapin@octobus.net>
parents:
46594
diff
changeset
|
11 |
use crate::revlog::node::NULL_NODE; |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
12 |
use crate::{ |
43605
8210c3f46912
rust: introduce SIZE_FROM_OTHER_PARENT constant
Raphaël Gomès <rgomes@octobus.net>
parents:
42957
diff
changeset
|
13 |
dirstate::{parsers::PARENT_SIZE, EntryState, SIZE_FROM_OTHER_PARENT}, |
42840
b1b984f9c01d
rust-utils: add normalize_case util to mirror Python one
Raphaël Gomès <rgomes@octobus.net>
parents:
42802
diff
changeset
|
14 |
pack_dirstate, parse_dirstate, |
43605
8210c3f46912
rust: introduce SIZE_FROM_OTHER_PARENT constant
Raphaël Gomès <rgomes@octobus.net>
parents:
42957
diff
changeset
|
15 |
utils::{ |
8210c3f46912
rust: introduce SIZE_FROM_OTHER_PARENT constant
Raphaël Gomès <rgomes@octobus.net>
parents:
42957
diff
changeset
|
16 |
files::normalize_case, |
8210c3f46912
rust: introduce SIZE_FROM_OTHER_PARENT constant
Raphaël Gomès <rgomes@octobus.net>
parents:
42957
diff
changeset
|
17 |
hg_path::{HgPath, HgPathBuf}, |
8210c3f46912
rust: introduce SIZE_FROM_OTHER_PARENT constant
Raphaël Gomès <rgomes@octobus.net>
parents:
42957
diff
changeset
|
18 |
}, |
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
19 |
CopyMap, DirsMultiset, DirstateEntry, DirstateError, DirstateMapError, |
46440
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46227
diff
changeset
|
20 |
DirstateParents, FastHashMap, StateMap, |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
21 |
}; |
45558
80bf7b1ada15
rust-dirstatemap: add #[timed] to dirstatemap read for comparison
Raphaël Gomès <rgomes@octobus.net>
parents:
45531
diff
changeset
|
22 |
use micro_timer::timed; |
43826
5ac243a92e37
rust-performance: introduce FastHashMap type alias for HashMap
Raphaël Gomès <rgomes@octobus.net>
parents:
43788
diff
changeset
|
23 |
use std::collections::HashSet; |
42799
5399532510ae
rust: simply use TryInto to convert slice to array
Yuya Nishihara <yuya@tcha.org>
parents:
42798
diff
changeset
|
24 |
use std::convert::TryInto; |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
25 |
use std::iter::FromIterator; |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
26 |
use std::ops::Deref; |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
27 |
|
43826
5ac243a92e37
rust-performance: introduce FastHashMap type alias for HashMap
Raphaël Gomès <rgomes@octobus.net>
parents:
43788
diff
changeset
|
28 |
pub type FileFoldMap = FastHashMap<HgPathBuf, HgPathBuf>; |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
29 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
30 |
const MTIME_UNSET: i32 = -1; |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
31 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
32 |
#[derive(Default)] |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
33 |
pub struct DirstateMap { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
34 |
state_map: StateMap, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
35 |
pub copy_map: CopyMap, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
36 |
file_fold_map: Option<FileFoldMap>, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
37 |
pub dirs: Option<DirsMultiset>, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
38 |
pub all_dirs: Option<DirsMultiset>, |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
39 |
non_normal_set: Option<HashSet<HgPathBuf>>, |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
40 |
other_parent_set: Option<HashSet<HgPathBuf>>, |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
41 |
parents: Option<DirstateParents>, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
42 |
dirty_parents: bool, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
43 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
44 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
45 |
/// Should only really be used in python interface code, for clarity |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
46 |
impl Deref for DirstateMap { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
47 |
type Target = StateMap; |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
48 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
49 |
fn deref(&self) -> &Self::Target { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
50 |
&self.state_map |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
51 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
52 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
53 |
|
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42840
diff
changeset
|
54 |
impl FromIterator<(HgPathBuf, DirstateEntry)> for DirstateMap { |
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
55 |
fn from_iter<I: IntoIterator<Item = (HgPathBuf, DirstateEntry)>>( |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
56 |
iter: I, |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
57 |
) -> Self { |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
58 |
Self { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
59 |
state_map: iter.into_iter().collect(), |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
60 |
..Self::default() |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
61 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
62 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
63 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
64 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
65 |
impl DirstateMap { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
66 |
pub fn new() -> Self { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
67 |
Self::default() |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
68 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
69 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
70 |
pub fn clear(&mut self) { |
45610
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
45588
diff
changeset
|
71 |
self.state_map = StateMap::default(); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
72 |
self.copy_map.clear(); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
73 |
self.file_fold_map = None; |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
74 |
self.non_normal_set = None; |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
75 |
self.other_parent_set = None; |
42801
1a535313ad1b
rust-dirstate: remove excessive clone() of parameter and return value
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
76 |
self.set_parents(&DirstateParents { |
46595
98a455a62699
rust: Make `DirstateParents`’s fields typed `Node`s
Simon Sapin <simon.sapin@octobus.net>
parents:
46594
diff
changeset
|
77 |
p1: NULL_NODE, |
98a455a62699
rust: Make `DirstateParents`’s fields typed `Node`s
Simon Sapin <simon.sapin@octobus.net>
parents:
46594
diff
changeset
|
78 |
p2: NULL_NODE, |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
79 |
}) |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
80 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
81 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
82 |
/// Add a tracked file to the dirstate |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
83 |
pub fn add_file( |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
84 |
&mut self, |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42840
diff
changeset
|
85 |
filename: &HgPath, |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
86 |
old_state: EntryState, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
87 |
entry: DirstateEntry, |
43788
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Raphaël Gomès <rgomes@octobus.net>
parents:
43605
diff
changeset
|
88 |
) -> Result<(), DirstateMapError> { |
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
89 |
if old_state == EntryState::Unknown || old_state == EntryState::Removed |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
90 |
{ |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
91 |
if let Some(ref mut dirs) = self.dirs { |
43788
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Raphaël Gomès <rgomes@octobus.net>
parents:
43605
diff
changeset
|
92 |
dirs.add_path(filename)?; |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
93 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
94 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
95 |
if old_state == EntryState::Unknown { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
96 |
if let Some(ref mut all_dirs) = self.all_dirs { |
43788
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Raphaël Gomès <rgomes@octobus.net>
parents:
43605
diff
changeset
|
97 |
all_dirs.add_path(filename)?; |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
98 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
99 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
100 |
self.state_map.insert(filename.to_owned(), entry.to_owned()); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
101 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
102 |
if entry.state != EntryState::Normal || entry.mtime == MTIME_UNSET { |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
103 |
self.get_non_normal_other_parent_entries() |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
104 |
.0 |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
105 |
.insert(filename.to_owned()); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
106 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
107 |
|
43605
8210c3f46912
rust: introduce SIZE_FROM_OTHER_PARENT constant
Raphaël Gomès <rgomes@octobus.net>
parents:
42957
diff
changeset
|
108 |
if entry.size == SIZE_FROM_OTHER_PARENT { |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
109 |
self.get_non_normal_other_parent_entries() |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
110 |
.1 |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
111 |
.insert(filename.to_owned()); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
112 |
} |
43788
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Raphaël Gomès <rgomes@octobus.net>
parents:
43605
diff
changeset
|
113 |
Ok(()) |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
114 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
115 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
116 |
/// Mark a file as removed in the dirstate. |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
117 |
/// |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
118 |
/// The `size` parameter is used to store sentinel values that indicate |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
119 |
/// the file's previous state. In the future, we should refactor this |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
120 |
/// to be more explicit about what that state is. |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
121 |
pub fn remove_file( |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
122 |
&mut self, |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42840
diff
changeset
|
123 |
filename: &HgPath, |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
124 |
old_state: EntryState, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
125 |
size: i32, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
126 |
) -> Result<(), DirstateMapError> { |
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
127 |
if old_state != EntryState::Unknown && old_state != EntryState::Removed |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
128 |
{ |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
129 |
if let Some(ref mut dirs) = self.dirs { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
130 |
dirs.delete_path(filename)?; |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
131 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
132 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
133 |
if old_state == EntryState::Unknown { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
134 |
if let Some(ref mut all_dirs) = self.all_dirs { |
43863
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43826
diff
changeset
|
135 |
all_dirs.add_path(filename)?; |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
136 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
137 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
138 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
139 |
if let Some(ref mut file_fold_map) = self.file_fold_map { |
42840
b1b984f9c01d
rust-utils: add normalize_case util to mirror Python one
Raphaël Gomès <rgomes@octobus.net>
parents:
42802
diff
changeset
|
140 |
file_fold_map.remove(&normalize_case(filename)); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
141 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
142 |
self.state_map.insert( |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
143 |
filename.to_owned(), |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
144 |
DirstateEntry { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
145 |
state: EntryState::Removed, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
146 |
mode: 0, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
147 |
size, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
148 |
mtime: 0, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
149 |
}, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
150 |
); |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
151 |
self.get_non_normal_other_parent_entries() |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
152 |
.0 |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
153 |
.insert(filename.to_owned()); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
154 |
Ok(()) |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
155 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
156 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
157 |
/// Remove a file from the dirstate. |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
158 |
/// Returns `true` if the file was previously recorded. |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
159 |
pub fn drop_file( |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
160 |
&mut self, |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42840
diff
changeset
|
161 |
filename: &HgPath, |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
162 |
old_state: EntryState, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
163 |
) -> Result<bool, DirstateMapError> { |
42795
8d2d5dfa07f5
rust-dirstate: remove too abstracted way of getting &[u8]
Yuya Nishihara <yuya@tcha.org>
parents:
42753
diff
changeset
|
164 |
let exists = self.state_map.remove(filename).is_some(); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
165 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
166 |
if exists { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
167 |
if old_state != EntryState::Removed { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
168 |
if let Some(ref mut dirs) = self.dirs { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
169 |
dirs.delete_path(filename)?; |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
170 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
171 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
172 |
if let Some(ref mut all_dirs) = self.all_dirs { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
173 |
all_dirs.delete_path(filename)?; |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
174 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
175 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
176 |
if let Some(ref mut file_fold_map) = self.file_fold_map { |
42840
b1b984f9c01d
rust-utils: add normalize_case util to mirror Python one
Raphaël Gomès <rgomes@octobus.net>
parents:
42802
diff
changeset
|
177 |
file_fold_map.remove(&normalize_case(filename)); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
178 |
} |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
179 |
self.get_non_normal_other_parent_entries() |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
180 |
.0 |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
181 |
.remove(filename); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
182 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
183 |
Ok(exists) |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
184 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
185 |
|
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
186 |
pub fn clear_ambiguous_times( |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
187 |
&mut self, |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
188 |
filenames: Vec<HgPathBuf>, |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
189 |
now: i32, |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
190 |
) { |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
191 |
for filename in filenames { |
45610
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
45588
diff
changeset
|
192 |
if let Some(entry) = self.state_map.get_mut(&filename) { |
47105
ba17a2ee85ac
dirstate-tree: Add clear_ambiguous_times in the new DirstateMap
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
193 |
if clear_ambiguous_mtime(entry, now) { |
ba17a2ee85ac
dirstate-tree: Add clear_ambiguous_times in the new DirstateMap
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
194 |
self.get_non_normal_other_parent_entries() |
ba17a2ee85ac
dirstate-tree: Add clear_ambiguous_times in the new DirstateMap
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
195 |
.0 |
ba17a2ee85ac
dirstate-tree: Add clear_ambiguous_times in the new DirstateMap
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
196 |
.insert(filename.to_owned()); |
45610
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
45588
diff
changeset
|
197 |
} |
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
45588
diff
changeset
|
198 |
} |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
199 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
200 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
201 |
|
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
202 |
pub fn non_normal_entries_remove( |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
203 |
&mut self, |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
204 |
key: impl AsRef<HgPath>, |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
205 |
) -> bool { |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
206 |
self.get_non_normal_other_parent_entries() |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
207 |
.0 |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
208 |
.remove(key.as_ref()) |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
209 |
} |
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
210 |
pub fn non_normal_entries_union( |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
211 |
&mut self, |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
212 |
other: HashSet<HgPathBuf>, |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
213 |
) -> Vec<HgPathBuf> { |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
214 |
self.get_non_normal_other_parent_entries() |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
215 |
.0 |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
216 |
.union(&other) |
44973
26114bd6ec60
rust: do a clippy pass
Raphaël Gomès <rgomes@octobus.net>
parents:
44416
diff
changeset
|
217 |
.map(ToOwned::to_owned) |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
218 |
.collect() |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
219 |
} |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
220 |
|
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
221 |
pub fn get_non_normal_other_parent_entries( |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
222 |
&mut self, |
44362
c089a0947f3e
rust-dirstatemap: directly return `non_normal` and `other_entries`
Raphaël Gomès <rgomes@octobus.net>
parents:
44293
diff
changeset
|
223 |
) -> (&mut HashSet<HgPathBuf>, &mut HashSet<HgPathBuf>) { |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
224 |
self.set_non_normal_other_parent_entries(false); |
44362
c089a0947f3e
rust-dirstatemap: directly return `non_normal` and `other_entries`
Raphaël Gomès <rgomes@octobus.net>
parents:
44293
diff
changeset
|
225 |
( |
c089a0947f3e
rust-dirstatemap: directly return `non_normal` and `other_entries`
Raphaël Gomès <rgomes@octobus.net>
parents:
44293
diff
changeset
|
226 |
self.non_normal_set.as_mut().unwrap(), |
c089a0947f3e
rust-dirstatemap: directly return `non_normal` and `other_entries`
Raphaël Gomès <rgomes@octobus.net>
parents:
44293
diff
changeset
|
227 |
self.other_parent_set.as_mut().unwrap(), |
c089a0947f3e
rust-dirstatemap: directly return `non_normal` and `other_entries`
Raphaël Gomès <rgomes@octobus.net>
parents:
44293
diff
changeset
|
228 |
) |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
229 |
} |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
230 |
|
44416
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
231 |
/// Useful to get immutable references to those sets in contexts where |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
232 |
/// you only have an immutable reference to the `DirstateMap`, like when |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
233 |
/// sharing references with Python. |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
234 |
/// |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
235 |
/// TODO, get rid of this along with the other "setter/getter" stuff when |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
236 |
/// a nice typestate plan is defined. |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
237 |
/// |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
238 |
/// # Panics |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
239 |
/// |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
240 |
/// Will panic if either set is `None`. |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
241 |
pub fn get_non_normal_other_parent_entries_panic( |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
242 |
&self, |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
243 |
) -> (&HashSet<HgPathBuf>, &HashSet<HgPathBuf>) { |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
244 |
( |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
245 |
self.non_normal_set.as_ref().unwrap(), |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
246 |
self.other_parent_set.as_ref().unwrap(), |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
247 |
) |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
248 |
} |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
249 |
|
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
250 |
pub fn set_non_normal_other_parent_entries(&mut self, force: bool) { |
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
251 |
if !force |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
252 |
&& self.non_normal_set.is_some() |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
253 |
&& self.other_parent_set.is_some() |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
254 |
{ |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
255 |
return; |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
256 |
} |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
257 |
let mut non_normal = HashSet::new(); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
258 |
let mut other_parent = HashSet::new(); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
259 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
260 |
for ( |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
261 |
filename, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
262 |
DirstateEntry { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
263 |
state, size, mtime, .. |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
264 |
}, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
265 |
) in self.state_map.iter() |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
266 |
{ |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
267 |
if *state != EntryState::Normal || *mtime == MTIME_UNSET { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
268 |
non_normal.insert(filename.to_owned()); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
269 |
} |
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
270 |
if *state == EntryState::Normal && *size == SIZE_FROM_OTHER_PARENT |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
271 |
{ |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
272 |
other_parent.insert(filename.to_owned()); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
273 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
274 |
} |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
275 |
self.non_normal_set = Some(non_normal); |
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
276 |
self.other_parent_set = Some(other_parent); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
277 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
278 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
279 |
/// Both of these setters and their uses appear to be the simplest way to |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
280 |
/// emulate a Python lazy property, but it is ugly and unidiomatic. |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
281 |
/// TODO One day, rewriting this struct using the typestate might be a |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
282 |
/// good idea. |
43863
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43826
diff
changeset
|
283 |
pub fn set_all_dirs(&mut self) -> Result<(), DirstateMapError> { |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
284 |
if self.all_dirs.is_none() { |
47093
787ff5d21bcd
dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
46890
diff
changeset
|
285 |
self.all_dirs = Some(DirsMultiset::from_dirstate( |
787ff5d21bcd
dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
46890
diff
changeset
|
286 |
self.state_map.iter(), |
787ff5d21bcd
dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
46890
diff
changeset
|
287 |
None, |
787ff5d21bcd
dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
46890
diff
changeset
|
288 |
)?); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
289 |
} |
43863
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43826
diff
changeset
|
290 |
Ok(()) |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
291 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
292 |
|
43863
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43826
diff
changeset
|
293 |
pub fn set_dirs(&mut self) -> Result<(), DirstateMapError> { |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
294 |
if self.dirs.is_none() { |
42802
2e1f74cc3350
rust-dirstate: split DirsMultiset constructor per input type
Yuya Nishihara <yuya@tcha.org>
parents:
42801
diff
changeset
|
295 |
self.dirs = Some(DirsMultiset::from_dirstate( |
2e1f74cc3350
rust-dirstate: split DirsMultiset constructor per input type
Yuya Nishihara <yuya@tcha.org>
parents:
42801
diff
changeset
|
296 |
&self.state_map, |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
297 |
Some(EntryState::Removed), |
43863
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43826
diff
changeset
|
298 |
)?); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
299 |
} |
43863
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43826
diff
changeset
|
300 |
Ok(()) |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
301 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
302 |
|
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
303 |
pub fn has_tracked_dir( |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
304 |
&mut self, |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
305 |
directory: &HgPath, |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
306 |
) -> Result<bool, DirstateMapError> { |
43863
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43826
diff
changeset
|
307 |
self.set_dirs()?; |
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43826
diff
changeset
|
308 |
Ok(self.dirs.as_ref().unwrap().contains(directory)) |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
309 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
310 |
|
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
311 |
pub fn has_dir( |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
312 |
&mut self, |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
313 |
directory: &HgPath, |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
314 |
) -> Result<bool, DirstateMapError> { |
43863
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43826
diff
changeset
|
315 |
self.set_all_dirs()?; |
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43826
diff
changeset
|
316 |
Ok(self.all_dirs.as_ref().unwrap().contains(directory)) |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
317 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
318 |
|
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
319 |
pub fn parents( |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
320 |
&mut self, |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
321 |
file_contents: &[u8], |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
322 |
) -> Result<&DirstateParents, DirstateError> { |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
323 |
if let Some(ref parents) = self.parents { |
42801
1a535313ad1b
rust-dirstate: remove excessive clone() of parameter and return value
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
324 |
return Ok(parents); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
325 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
326 |
let parents; |
42798
99dff4264524
rust-dirstate: use PARENT_SIZE constant where appropriate
Yuya Nishihara <yuya@tcha.org>
parents:
42797
diff
changeset
|
327 |
if file_contents.len() == PARENT_SIZE * 2 { |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
328 |
parents = DirstateParents { |
42799
5399532510ae
rust: simply use TryInto to convert slice to array
Yuya Nishihara <yuya@tcha.org>
parents:
42798
diff
changeset
|
329 |
p1: file_contents[..PARENT_SIZE].try_into().unwrap(), |
5399532510ae
rust: simply use TryInto to convert slice to array
Yuya Nishihara <yuya@tcha.org>
parents:
42798
diff
changeset
|
330 |
p2: file_contents[PARENT_SIZE..PARENT_SIZE * 2] |
5399532510ae
rust: simply use TryInto to convert slice to array
Yuya Nishihara <yuya@tcha.org>
parents:
42798
diff
changeset
|
331 |
.try_into() |
5399532510ae
rust: simply use TryInto to convert slice to array
Yuya Nishihara <yuya@tcha.org>
parents:
42798
diff
changeset
|
332 |
.unwrap(), |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
333 |
}; |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
334 |
} else if file_contents.is_empty() { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
335 |
parents = DirstateParents { |
46595
98a455a62699
rust: Make `DirstateParents`’s fields typed `Node`s
Simon Sapin <simon.sapin@octobus.net>
parents:
46594
diff
changeset
|
336 |
p1: NULL_NODE, |
98a455a62699
rust: Make `DirstateParents`’s fields typed `Node`s
Simon Sapin <simon.sapin@octobus.net>
parents:
46594
diff
changeset
|
337 |
p2: NULL_NODE, |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
338 |
}; |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
339 |
} else { |
46440
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46227
diff
changeset
|
340 |
return Err( |
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46227
diff
changeset
|
341 |
HgError::corrupted("Dirstate appears to be damaged").into() |
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46227
diff
changeset
|
342 |
); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
343 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
344 |
|
42801
1a535313ad1b
rust-dirstate: remove excessive clone() of parameter and return value
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
345 |
self.parents = Some(parents); |
1a535313ad1b
rust-dirstate: remove excessive clone() of parameter and return value
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
346 |
Ok(self.parents.as_ref().unwrap()) |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
347 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
348 |
|
42801
1a535313ad1b
rust-dirstate: remove excessive clone() of parameter and return value
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
349 |
pub fn set_parents(&mut self, parents: &DirstateParents) { |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
350 |
self.parents = Some(parents.clone()); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
351 |
self.dirty_parents = true; |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
352 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
353 |
|
45558
80bf7b1ada15
rust-dirstatemap: add #[timed] to dirstatemap read for comparison
Raphaël Gomès <rgomes@octobus.net>
parents:
45531
diff
changeset
|
354 |
#[timed] |
46594
f88e8ae0aa8f
rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents:
46440
diff
changeset
|
355 |
pub fn read<'a>( |
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
356 |
&mut self, |
46594
f88e8ae0aa8f
rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents:
46440
diff
changeset
|
357 |
file_contents: &'a [u8], |
f88e8ae0aa8f
rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents:
46440
diff
changeset
|
358 |
) -> Result<Option<&'a DirstateParents>, DirstateError> { |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
359 |
if file_contents.is_empty() { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
360 |
return Ok(None); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
361 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
362 |
|
45357
27424779c5b8
hg-core: make parse_dirstate return references rather than update hashmaps
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44973
diff
changeset
|
363 |
let (parents, entries, copies) = parse_dirstate(file_contents)?; |
27424779c5b8
hg-core: make parse_dirstate return references rather than update hashmaps
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44973
diff
changeset
|
364 |
self.state_map.extend( |
27424779c5b8
hg-core: make parse_dirstate return references rather than update hashmaps
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44973
diff
changeset
|
365 |
entries |
27424779c5b8
hg-core: make parse_dirstate return references rather than update hashmaps
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44973
diff
changeset
|
366 |
.into_iter() |
27424779c5b8
hg-core: make parse_dirstate return references rather than update hashmaps
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44973
diff
changeset
|
367 |
.map(|(path, entry)| (path.to_owned(), entry)), |
27424779c5b8
hg-core: make parse_dirstate return references rather than update hashmaps
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44973
diff
changeset
|
368 |
); |
27424779c5b8
hg-core: make parse_dirstate return references rather than update hashmaps
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44973
diff
changeset
|
369 |
self.copy_map.extend( |
27424779c5b8
hg-core: make parse_dirstate return references rather than update hashmaps
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44973
diff
changeset
|
370 |
copies |
27424779c5b8
hg-core: make parse_dirstate return references rather than update hashmaps
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44973
diff
changeset
|
371 |
.into_iter() |
27424779c5b8
hg-core: make parse_dirstate return references rather than update hashmaps
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44973
diff
changeset
|
372 |
.map(|(path, copy)| (path.to_owned(), copy.to_owned())), |
27424779c5b8
hg-core: make parse_dirstate return references rather than update hashmaps
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44973
diff
changeset
|
373 |
); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
374 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
375 |
if !self.dirty_parents { |
42801
1a535313ad1b
rust-dirstate: remove excessive clone() of parameter and return value
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
376 |
self.set_parents(&parents); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
377 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
378 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
379 |
Ok(Some(parents)) |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
380 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
381 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
382 |
pub fn pack( |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
383 |
&mut self, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
384 |
parents: DirstateParents, |
47101
5d62243c7732
rust: Add a Timestamp struct instead of abusing Duration
Simon Sapin <simon.sapin@octobus.net>
parents:
47093
diff
changeset
|
385 |
now: Timestamp, |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
386 |
) -> Result<Vec<u8>, DirstateError> { |
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
387 |
let packed = |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
388 |
pack_dirstate(&mut self.state_map, &self.copy_map, parents, now)?; |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
389 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
390 |
self.dirty_parents = false; |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
391 |
|
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
392 |
self.set_non_normal_other_parent_entries(true); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
393 |
Ok(packed) |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
394 |
} |
42801
1a535313ad1b
rust-dirstate: remove excessive clone() of parameter and return value
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
395 |
pub fn build_file_fold_map(&mut self) -> &FileFoldMap { |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
396 |
if let Some(ref file_fold_map) = self.file_fold_map { |
42801
1a535313ad1b
rust-dirstate: remove excessive clone() of parameter and return value
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
397 |
return file_fold_map; |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
398 |
} |
43826
5ac243a92e37
rust-performance: introduce FastHashMap type alias for HashMap
Raphaël Gomès <rgomes@octobus.net>
parents:
43788
diff
changeset
|
399 |
let mut new_file_fold_map = FileFoldMap::default(); |
45610
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
45588
diff
changeset
|
400 |
|
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
45588
diff
changeset
|
401 |
for (filename, DirstateEntry { state, .. }) in self.state_map.iter() { |
46227
5bae4bc9bd42
rust: fix file folding map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
45610
diff
changeset
|
402 |
if *state != EntryState::Removed { |
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
403 |
new_file_fold_map |
45610
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
45588
diff
changeset
|
404 |
.insert(normalize_case(&filename), filename.to_owned()); |
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
45588
diff
changeset
|
405 |
} |
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
45588
diff
changeset
|
406 |
} |
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
45588
diff
changeset
|
407 |
self.file_fold_map = Some(new_file_fold_map); |
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
45588
diff
changeset
|
408 |
self.file_fold_map.as_ref().unwrap() |
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
45588
diff
changeset
|
409 |
} |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
410 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
411 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
412 |
#[cfg(test)] |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
413 |
mod tests { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
414 |
use super::*; |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
415 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
416 |
#[test] |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
417 |
fn test_dirs_multiset() { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
418 |
let mut map = DirstateMap::new(); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
419 |
assert!(map.dirs.is_none()); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
420 |
assert!(map.all_dirs.is_none()); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
421 |
|
43863
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43826
diff
changeset
|
422 |
assert_eq!(map.has_dir(HgPath::new(b"nope")).unwrap(), false); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
423 |
assert!(map.all_dirs.is_some()); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
424 |
assert!(map.dirs.is_none()); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
425 |
|
43863
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43826
diff
changeset
|
426 |
assert_eq!(map.has_tracked_dir(HgPath::new(b"nope")).unwrap(), false); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
427 |
assert!(map.dirs.is_some()); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
428 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
429 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
430 |
#[test] |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
431 |
fn test_add_file() { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
432 |
let mut map = DirstateMap::new(); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
433 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
434 |
assert_eq!(0, map.len()); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
435 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
436 |
map.add_file( |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42840
diff
changeset
|
437 |
HgPath::new(b"meh"), |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
438 |
EntryState::Normal, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
439 |
DirstateEntry { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
440 |
state: EntryState::Normal, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
441 |
mode: 1337, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
442 |
mtime: 1337, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
443 |
size: 1337, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
444 |
}, |
43890
d8a96cebf75d
rust-warnings: fix warnings in tests
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
445 |
) |
d8a96cebf75d
rust-warnings: fix warnings in tests
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
446 |
.unwrap(); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
447 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
448 |
assert_eq!(1, map.len()); |
44362
c089a0947f3e
rust-dirstatemap: directly return `non_normal` and `other_entries`
Raphaël Gomès <rgomes@octobus.net>
parents:
44293
diff
changeset
|
449 |
assert_eq!(0, map.get_non_normal_other_parent_entries().0.len()); |
c089a0947f3e
rust-dirstatemap: directly return `non_normal` and `other_entries`
Raphaël Gomès <rgomes@octobus.net>
parents:
44293
diff
changeset
|
450 |
assert_eq!(0, map.get_non_normal_other_parent_entries().1.len()); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
451 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
452 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
453 |
#[test] |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
454 |
fn test_non_normal_other_parent_entries() { |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
455 |
let mut map: DirstateMap = [ |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
456 |
(b"f1", (EntryState::Removed, 1337, 1337, 1337)), |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
457 |
(b"f2", (EntryState::Normal, 1337, 1337, -1)), |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
458 |
(b"f3", (EntryState::Normal, 1337, 1337, 1337)), |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
459 |
(b"f4", (EntryState::Normal, 1337, -2, 1337)), |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
460 |
(b"f5", (EntryState::Added, 1337, 1337, 1337)), |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
461 |
(b"f6", (EntryState::Added, 1337, 1337, -1)), |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
462 |
(b"f7", (EntryState::Merged, 1337, 1337, -1)), |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
463 |
(b"f8", (EntryState::Merged, 1337, 1337, 1337)), |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
464 |
(b"f9", (EntryState::Merged, 1337, -2, 1337)), |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
465 |
(b"fa", (EntryState::Added, 1337, -2, 1337)), |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
466 |
(b"fb", (EntryState::Removed, 1337, -2, 1337)), |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
467 |
] |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
468 |
.iter() |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
469 |
.map(|(fname, (state, mode, size, mtime))| { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
470 |
( |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42840
diff
changeset
|
471 |
HgPathBuf::from_bytes(fname.as_ref()), |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
472 |
DirstateEntry { |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
473 |
state: *state, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
474 |
mode: *mode, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
475 |
size: *size, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
476 |
mtime: *mtime, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
477 |
}, |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
478 |
) |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
479 |
}) |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
480 |
.collect(); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
481 |
|
44362
c089a0947f3e
rust-dirstatemap: directly return `non_normal` and `other_entries`
Raphaël Gomès <rgomes@octobus.net>
parents:
44293
diff
changeset
|
482 |
let mut non_normal = [ |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
483 |
b"f1", b"f2", b"f5", b"f6", b"f7", b"f8", b"f9", b"fa", b"fb", |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
484 |
] |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
485 |
.iter() |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42840
diff
changeset
|
486 |
.map(|x| HgPathBuf::from_bytes(x.as_ref())) |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
487 |
.collect(); |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
488 |
|
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
489 |
let mut other_parent = HashSet::new(); |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42840
diff
changeset
|
490 |
other_parent.insert(HgPathBuf::from_bytes(b"f4")); |
44293
83b2b829c94e
rust-dirstatemap: cache non normal and other parent set
Raphaël Gomès <rgomes@octobus.net>
parents:
43890
diff
changeset
|
491 |
let entries = map.get_non_normal_other_parent_entries(); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
492 |
|
45588
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
493 |
assert_eq!( |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
494 |
(&mut non_normal, &mut other_parent), |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
495 |
(entries.0, entries.1) |
c35db907363d
rust: format with rustfmt
Raphaël Gomès <rgomes@octobus.net>
parents:
45558
diff
changeset
|
496 |
); |
42753
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
497 |
} |
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
498 |
} |