Show More
@@ -28,6 +28,17 b' enum Dispatch {' | |||||
28 | Unknown, |
|
28 | Unknown, | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
|
31 | /// Dates and times that are outside the 31-bit signed range are compared | |||
|
32 | /// modulo 2^31. This should prevent hg from behaving badly with very large | |||
|
33 | /// files or corrupt dates while still having a high probability of detecting | |||
|
34 | /// changes. (issue2608) | |||
|
35 | /// TODO I haven't found a way of having `b` be `Into<i32>`, since `From<u64>` | |||
|
36 | /// is not defined for `i32`, and there is no `As` trait. This forces the | |||
|
37 | /// caller to cast `b` as `i32`. | |||
|
38 | fn mod_compare(a: i32, b: i32) -> bool { | |||
|
39 | a & i32::max_value() != b & i32::max_value() | |||
|
40 | } | |||
|
41 | ||||
31 | /// The file corresponding to the dirstate entry was found on the filesystem. |
|
42 | /// The file corresponding to the dirstate entry was found on the filesystem. | |
32 | fn dispatch_found( |
|
43 | fn dispatch_found( | |
33 | filename: impl AsRef<HgPath>, |
|
44 | filename: impl AsRef<HgPath>, | |
@@ -54,26 +65,17 b' fn dispatch_found(' | |||||
54 |
|
65 | |||
55 | match state { |
|
66 | match state { | |
56 | EntryState::Normal => { |
|
67 | EntryState::Normal => { | |
57 | // Dates and times that are outside the 31-bit signed |
|
68 | let size_changed = mod_compare(size, st_size as i32); | |
58 | // range are compared modulo 2^31. This should prevent |
|
|||
59 | // it from behaving badly with very large files or |
|
|||
60 | // corrupt dates while still having a high probability |
|
|||
61 | // of detecting changes. (issue2608) |
|
|||
62 | let range_mask = 0x7fffffff; |
|
|||
63 |
|
||||
64 | let size_changed = (size != st_size as i32) |
|
|||
65 | && size != (st_size as i32 & range_mask); |
|
|||
66 | let mode_changed = |
|
69 | let mode_changed = | |
67 | (mode ^ st_mode as i32) & 0o100 != 0o000 && check_exec; |
|
70 | (mode ^ st_mode as i32) & 0o100 != 0o000 && check_exec; | |
68 | if size >= 0 |
|
71 | let metadata_changed = size >= 0 && (size_changed || mode_changed); | |
69 | && (size_changed || mode_changed) |
|
72 | let other_parent = size == -2; | |
70 | || size == -2 // other parent |
|
73 | if metadata_changed | |
71 | || copy_map.contains_key(filename.as_ref()) |
|
74 | || other_parent | |
|
75 | || copy_map.contains_key(filename.as_ref()) | |||
72 | { |
|
76 | { | |
73 | Dispatch::Modified |
|
77 | Dispatch::Modified | |
74 |
} else if mtime |
|
78 | } else if mod_compare(mtime, st_mtime as i32) { | |
75 | && mtime != (st_mtime as i32 & range_mask) |
|
|||
76 | { |
|
|||
77 | Dispatch::Unsure |
|
79 | Dispatch::Unsure | |
78 | } else if st_mtime == last_normal_time { |
|
80 | } else if st_mtime == last_normal_time { | |
79 | // the file may have just been marked as normal and |
|
81 | // the file may have just been marked as normal and |
General Comments 0
You need to be logged in to leave comments.
Login now