##// 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 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 40 pub type StateMap = HashMap<HgPathBuf, DirstateEntry>;
36 41 pub type StateMapIter<'a> = hash_map::Iter<'a, HgPathBuf, DirstateEntry>;
37 42 pub type CopyMap = HashMap<HgPathBuf, HgPathBuf>;
@@ -5,11 +5,13 b''
5 5 // This software may be used and distributed according to the terms of the
6 6 // GNU General Public License version 2 or any later version.
7 7
8 use crate::utils::hg_path::{HgPath, HgPathBuf};
9 8 use crate::{
10 dirstate::{parsers::PARENT_SIZE, EntryState},
9 dirstate::{parsers::PARENT_SIZE, EntryState, SIZE_FROM_OTHER_PARENT},
11 10 pack_dirstate, parse_dirstate,
12 utils::files::normalize_case,
11 utils::{
12 files::normalize_case,
13 hg_path::{HgPath, HgPathBuf},
14 },
13 15 CopyMap, DirsMultiset, DirstateEntry, DirstateError, DirstateMapError,
14 16 DirstateParents, DirstateParseError, StateMap,
15 17 };
@@ -24,7 +26,6 b' pub type FileFoldMap = HashMap<HgPathBuf'
24 26
25 27 const NULL_ID: [u8; 20] = [0; 20];
26 28 const MTIME_UNSET: i32 = -1;
27 const SIZE_DIRTY: i32 = -2;
28 29
29 30 #[derive(Default)]
30 31 pub struct DirstateMap {
@@ -100,7 +101,7 b' impl DirstateMap {'
100 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 105 self.other_parent_set.insert(filename.to_owned());
105 106 }
106 107 }
@@ -212,7 +213,8 b' impl DirstateMap {'
212 213 if *state != EntryState::Normal || *mtime == MTIME_UNSET {
213 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 218 other_parent.insert(filename.to_owned());
217 219 }
218 220 }
@@ -9,9 +9,14 b''
9 9 //! It is currently missing a lot of functionality compared to the Python one
10 10 //! and will only be triggered in narrow cases.
11 11
12 use crate::utils::files::HgMetadata;
13 use crate::utils::hg_path::{hg_path_to_path_buf, HgPath};
14 use crate::{CopyMap, DirstateEntry, DirstateMap, EntryState};
12 use crate::{
13 dirstate::SIZE_FROM_OTHER_PARENT,
14 utils::{
15 files::HgMetadata,
16 hg_path::{hg_path_to_path_buf, HgPath},
17 },
18 CopyMap, DirstateEntry, DirstateMap, EntryState,
19 };
15 20 use rayon::prelude::*;
16 21 use std::path::Path;
17 22
@@ -69,7 +74,7 b' fn dispatch_found('
69 74 let mode_changed =
70 75 (mode ^ st_mode as i32) & 0o100 != 0o000 && check_exec;
71 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 78 if metadata_changed
74 79 || other_parent
75 80 || copy_map.contains_key(filename.as_ref())
General Comments 0
You need to be logged in to leave comments. Login now