##// END OF EJS Templates
rust: introduce SIZE_FROM_OTHER_PARENT constant...
Raphaël Gomès -
r44003:8210c3f4 default
parent child Browse files
Show More
@@ -32,6 +32,11 b' pub struct DirstateEntry {'
32 pub size: i32,
32 pub size: i32,
33 }
33 }
34
34
35 /// A `DirstateEntry` with a size of `-2` means that it was merged from the
36 /// other parent. This allows revert to pick the right status back during a
37 /// merge.
38 pub const SIZE_FROM_OTHER_PARENT: i32 = -2;
39
35 pub type StateMap = HashMap<HgPathBuf, DirstateEntry>;
40 pub type StateMap = HashMap<HgPathBuf, DirstateEntry>;
36 pub type StateMapIter<'a> = hash_map::Iter<'a, HgPathBuf, DirstateEntry>;
41 pub type StateMapIter<'a> = hash_map::Iter<'a, HgPathBuf, DirstateEntry>;
37 pub type CopyMap = HashMap<HgPathBuf, HgPathBuf>;
42 pub type CopyMap = HashMap<HgPathBuf, HgPathBuf>;
@@ -5,11 +5,13 b''
5 // This software may be used and distributed according to the terms of the
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.
6 // GNU General Public License version 2 or any later version.
7
7
8 use crate::utils::hg_path::{HgPath, HgPathBuf};
9 use crate::{
8 use crate::{
10 dirstate::{parsers::PARENT_SIZE, EntryState},
9 dirstate::{parsers::PARENT_SIZE, EntryState, SIZE_FROM_OTHER_PARENT},
11 pack_dirstate, parse_dirstate,
10 pack_dirstate, parse_dirstate,
12 utils::files::normalize_case,
11 utils::{
12 files::normalize_case,
13 hg_path::{HgPath, HgPathBuf},
14 },
13 CopyMap, DirsMultiset, DirstateEntry, DirstateError, DirstateMapError,
15 CopyMap, DirsMultiset, DirstateEntry, DirstateError, DirstateMapError,
14 DirstateParents, DirstateParseError, StateMap,
16 DirstateParents, DirstateParseError, StateMap,
15 };
17 };
@@ -24,7 +26,6 b' pub type FileFoldMap = HashMap<HgPathBuf'
24
26
25 const NULL_ID: [u8; 20] = [0; 20];
27 const NULL_ID: [u8; 20] = [0; 20];
26 const MTIME_UNSET: i32 = -1;
28 const MTIME_UNSET: i32 = -1;
27 const SIZE_DIRTY: i32 = -2;
28
29
29 #[derive(Default)]
30 #[derive(Default)]
30 pub struct DirstateMap {
31 pub struct DirstateMap {
@@ -100,7 +101,7 b' impl DirstateMap {'
100 self.non_normal_set.insert(filename.to_owned());
101 self.non_normal_set.insert(filename.to_owned());
101 }
102 }
102
103
103 if entry.size == SIZE_DIRTY {
104 if entry.size == SIZE_FROM_OTHER_PARENT {
104 self.other_parent_set.insert(filename.to_owned());
105 self.other_parent_set.insert(filename.to_owned());
105 }
106 }
106 }
107 }
@@ -212,7 +213,8 b' impl DirstateMap {'
212 if *state != EntryState::Normal || *mtime == MTIME_UNSET {
213 if *state != EntryState::Normal || *mtime == MTIME_UNSET {
213 non_normal.insert(filename.to_owned());
214 non_normal.insert(filename.to_owned());
214 }
215 }
215 if *state == EntryState::Normal && *size == SIZE_DIRTY {
216 if *state == EntryState::Normal && *size == SIZE_FROM_OTHER_PARENT
217 {
216 other_parent.insert(filename.to_owned());
218 other_parent.insert(filename.to_owned());
217 }
219 }
218 }
220 }
@@ -9,9 +9,14 b''
9 //! It is currently missing a lot of functionality compared to the Python one
9 //! It is currently missing a lot of functionality compared to the Python one
10 //! and will only be triggered in narrow cases.
10 //! and will only be triggered in narrow cases.
11
11
12 use crate::utils::files::HgMetadata;
12 use crate::{
13 use crate::utils::hg_path::{hg_path_to_path_buf, HgPath};
13 dirstate::SIZE_FROM_OTHER_PARENT,
14 use crate::{CopyMap, DirstateEntry, DirstateMap, EntryState};
14 utils::{
15 files::HgMetadata,
16 hg_path::{hg_path_to_path_buf, HgPath},
17 },
18 CopyMap, DirstateEntry, DirstateMap, EntryState,
19 };
15 use rayon::prelude::*;
20 use rayon::prelude::*;
16 use std::path::Path;
21 use std::path::Path;
17
22
@@ -69,7 +74,7 b' fn dispatch_found('
69 let mode_changed =
74 let mode_changed =
70 (mode ^ st_mode as i32) & 0o100 != 0o000 && check_exec;
75 (mode ^ st_mode as i32) & 0o100 != 0o000 && check_exec;
71 let metadata_changed = size >= 0 && (size_changed || mode_changed);
76 let metadata_changed = size >= 0 && (size_changed || mode_changed);
72 let other_parent = size == -2;
77 let other_parent = size == SIZE_FROM_OTHER_PARENT;
73 if metadata_changed
78 if metadata_changed
74 || other_parent
79 || other_parent
75 || copy_map.contains_key(filename.as_ref())
80 || copy_map.contains_key(filename.as_ref())
General Comments 0
You need to be logged in to leave comments. Login now