##// END OF EJS Templates
rust-dirstate-status: add first Rust implementation of `dirstate.status`...
Raphaël Gomès -
r43565:99394e6c default
parent child Browse files
Show More
@@ -0,0 +1,248 b''
1 // status.rs
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 //! Rust implementation of dirstate.status (dirstate.py).
9 //! It is currently missing a lot of functionality compared to the Python one
10 //! and will only be triggered in narrow cases.
11
12 use crate::utils::files::HgMetadata;
13 use crate::utils::hg_path::{hg_path_to_path_buf, HgPath, HgPathBuf};
14 use crate::{DirstateEntry, DirstateMap, EntryState};
15 use rayon::prelude::*;
16 use std::collections::HashMap;
17 use std::fs::Metadata;
18 use std::path::Path;
19
20 /// Get stat data about the files explicitly specified by match.
21 /// TODO subrepos
22 fn walk_explicit(
23 files: &[impl AsRef<HgPath> + Sync],
24 dmap: &DirstateMap,
25 root_dir: impl AsRef<Path> + Sync,
26 ) -> std::io::Result<HashMap<HgPathBuf, Option<HgMetadata>>> {
27 let mut results = HashMap::new();
28
29 // A tuple of the normalized filename and the `Result` of the call to
30 // `symlink_metadata` for separate handling.
31 type WalkTuple<'a> = (&'a HgPath, std::io::Result<Metadata>);
32
33 let stats_res: std::io::Result<Vec<WalkTuple>> = files
34 .par_iter()
35 .map(|filename| {
36 // TODO normalization
37 let normalized = filename.as_ref();
38
39 let target_filename =
40 root_dir.as_ref().join(hg_path_to_path_buf(normalized)?);
41
42 Ok((normalized, target_filename.symlink_metadata()))
43 })
44 .collect();
45
46 for res in stats_res? {
47 match res {
48 (normalized, Ok(stat)) => {
49 if stat.is_file() {
50 results.insert(
51 normalized.to_owned(),
52 Some(HgMetadata::from_metadata(stat)),
53 );
54 } else {
55 if dmap.contains_key(normalized) {
56 results.insert(normalized.to_owned(), None);
57 }
58 }
59 }
60 (normalized, Err(_)) => {
61 if dmap.contains_key(normalized) {
62 results.insert(normalized.to_owned(), None);
63 }
64 }
65 };
66 }
67
68 Ok(results)
69 }
70
71 // Stat all entries in the `DirstateMap` and return their new metadata.
72 pub fn stat_dmap_entries(
73 dmap: &DirstateMap,
74 results: &HashMap<HgPathBuf, Option<HgMetadata>>,
75 root_dir: impl AsRef<Path> + Sync,
76 ) -> std::io::Result<Vec<(HgPathBuf, Option<HgMetadata>)>> {
77 dmap.par_iter()
78 .filter_map(
79 // Getting file metadata is costly, so we don't do it if the
80 // file is already present in the results, hence `filter_map`
81 |(filename, _)| -> Option<
82 std::io::Result<(HgPathBuf, Option<HgMetadata>)>
83 > {
84 if results.contains_key(filename) {
85 return None;
86 }
87 let meta = match hg_path_to_path_buf(filename) {
88 Ok(p) => root_dir.as_ref().join(p).symlink_metadata(),
89 Err(e) => return Some(Err(e.into())),
90 };
91
92 Some(match meta {
93 Ok(ref m)
94 if !(m.file_type().is_file()
95 || m.file_type().is_symlink()) =>
96 {
97 Ok((filename.to_owned(), None))
98 }
99 Ok(m) => Ok((
100 filename.to_owned(),
101 Some(HgMetadata::from_metadata(m)),
102 )),
103 Err(ref e)
104 if e.kind() == std::io::ErrorKind::NotFound
105 || e.raw_os_error() == Some(20) =>
106 {
107 // Rust does not yet have an `ErrorKind` for
108 // `NotADirectory` (errno 20)
109 // It happens if the dirstate contains `foo/bar` and
110 // foo is not a directory
111 Ok((filename.to_owned(), None))
112 }
113 Err(e) => Err(e),
114 })
115 },
116 )
117 .collect()
118 }
119
120 pub struct StatusResult {
121 pub modified: Vec<HgPathBuf>,
122 pub added: Vec<HgPathBuf>,
123 pub removed: Vec<HgPathBuf>,
124 pub deleted: Vec<HgPathBuf>,
125 pub clean: Vec<HgPathBuf>,
126 // TODO ignored
127 // TODO unknown
128 }
129
130 fn build_response(
131 dmap: &DirstateMap,
132 list_clean: bool,
133 last_normal_time: i64,
134 check_exec: bool,
135 results: HashMap<HgPathBuf, Option<HgMetadata>>,
136 ) -> (Vec<HgPathBuf>, StatusResult) {
137 let mut lookup = vec![];
138 let mut modified = vec![];
139 let mut added = vec![];
140 let mut removed = vec![];
141 let mut deleted = vec![];
142 let mut clean = vec![];
143
144 for (filename, metadata_option) in results.into_iter() {
145 let DirstateEntry {
146 state,
147 mode,
148 mtime,
149 size,
150 } = match dmap.get(&filename) {
151 None => {
152 continue;
153 }
154 Some(e) => *e,
155 };
156
157 match metadata_option {
158 None => {
159 match state {
160 EntryState::Normal
161 | EntryState::Merged
162 | EntryState::Added => deleted.push(filename),
163 EntryState::Removed => removed.push(filename),
164 _ => {}
165 };
166 }
167 Some(HgMetadata {
168 st_mode,
169 st_size,
170 st_mtime,
171 ..
172 }) => {
173 match state {
174 EntryState::Normal => {
175 // Dates and times that are outside the 31-bit signed
176 // range are compared modulo 2^31. This should prevent
177 // it from behaving badly with very large files or
178 // corrupt dates while still having a high probability
179 // of detecting changes. (issue2608)
180 let range_mask = 0x7fffffff;
181
182 let size_changed = (size != st_size as i32)
183 && size != (st_size as i32 & range_mask);
184 let mode_changed = (mode ^ st_mode as i32) & 0o100
185 != 0o000
186 && check_exec;
187 if size >= 0
188 && (size_changed || mode_changed)
189 || size == -2 // other parent
190 || dmap.copy_map.contains_key(&filename)
191 {
192 modified.push(filename);
193 } else if mtime != st_mtime as i32
194 && mtime != (st_mtime as i32 & range_mask)
195 {
196 lookup.push(filename);
197 } else if st_mtime == last_normal_time {
198 // the file may have just been marked as normal and
199 // it may have changed in the same second without
200 // changing its size. This can happen if we quickly
201 // do multiple commits. Force lookup, so we don't
202 // miss such a racy file change.
203 lookup.push(filename);
204 } else if list_clean {
205 clean.push(filename);
206 }
207 }
208 EntryState::Merged => modified.push(filename),
209 EntryState::Added => added.push(filename),
210 EntryState::Removed => removed.push(filename),
211 EntryState::Unknown => {}
212 }
213 }
214 }
215 }
216
217 (
218 lookup,
219 StatusResult {
220 modified,
221 added,
222 removed,
223 deleted,
224 clean,
225 },
226 )
227 }
228
229 pub fn status(
230 dmap: &DirstateMap,
231 root_dir: impl AsRef<Path> + Sync + Copy,
232 files: &[impl AsRef<HgPath> + Sync],
233 list_clean: bool,
234 last_normal_time: i64,
235 check_exec: bool,
236 ) -> std::io::Result<(Vec<HgPathBuf>, StatusResult)> {
237 let mut results = walk_explicit(files, &dmap, root_dir)?;
238
239 results.extend(stat_dmap_entries(&dmap, &results, root_dir)?);
240
241 Ok(build_response(
242 &dmap,
243 list_clean,
244 last_normal_time,
245 check_exec,
246 results,
247 ))
248 }
@@ -2,25 +2,38 b''
2 2 # It is not intended for manual editing.
3 3 [[package]]
4 4 name = "aho-corasick"
5 version = "0.6.9"
5 version = "0.7.6"
6 6 source = "registry+https://github.com/rust-lang/crates.io-index"
7 7 dependencies = [
8 "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
8 "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
9 ]
10
11 [[package]]
12 name = "arrayvec"
13 version = "0.4.12"
14 source = "registry+https://github.com/rust-lang/crates.io-index"
15 dependencies = [
16 "nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
9 17 ]
10 18
11 19 [[package]]
12 20 name = "autocfg"
13 version = "0.1.2"
21 version = "0.1.6"
14 22 source = "registry+https://github.com/rust-lang/crates.io-index"
15 23
16 24 [[package]]
17 25 name = "bitflags"
18 version = "1.0.4"
26 version = "1.2.1"
19 27 source = "registry+https://github.com/rust-lang/crates.io-index"
20 28
21 29 [[package]]
22 30 name = "byteorder"
23 version = "1.3.1"
31 version = "1.3.2"
32 source = "registry+https://github.com/rust-lang/crates.io-index"
33
34 [[package]]
35 name = "cfg-if"
36 version = "0.1.10"
24 37 source = "registry+https://github.com/rust-lang/crates.io-index"
25 38
26 39 [[package]]
@@ -28,7 +41,7 b' name = "cloudabi"'
28 41 version = "0.0.3"
29 42 source = "registry+https://github.com/rust-lang/crates.io-index"
30 43 dependencies = [
31 "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
44 "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
32 45 ]
33 46
34 47 [[package]]
@@ -36,27 +49,72 b' name = "cpython"'
36 49 version = "0.3.0"
37 50 source = "registry+https://github.com/rust-lang/crates.io-index"
38 51 dependencies = [
39 "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
40 "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
52 "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
53 "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
41 54 "python27-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
42 55 "python3-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
43 56 ]
44 57
45 58 [[package]]
59 name = "crossbeam-deque"
60 version = "0.7.1"
61 source = "registry+https://github.com/rust-lang/crates.io-index"
62 dependencies = [
63 "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
64 "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
65 ]
66
67 [[package]]
68 name = "crossbeam-epoch"
69 version = "0.7.2"
70 source = "registry+https://github.com/rust-lang/crates.io-index"
71 dependencies = [
72 "arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
73 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
74 "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
75 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
76 "memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
77 "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
78 ]
79
80 [[package]]
81 name = "crossbeam-queue"
82 version = "0.1.2"
83 source = "registry+https://github.com/rust-lang/crates.io-index"
84 dependencies = [
85 "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
86 ]
87
88 [[package]]
89 name = "crossbeam-utils"
90 version = "0.6.6"
91 source = "registry+https://github.com/rust-lang/crates.io-index"
92 dependencies = [
93 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
94 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
95 ]
96
97 [[package]]
98 name = "either"
99 version = "1.5.3"
100 source = "registry+https://github.com/rust-lang/crates.io-index"
101
102 [[package]]
46 103 name = "fuchsia-cprng"
47 version = "0.1.0"
104 version = "0.1.1"
48 105 source = "registry+https://github.com/rust-lang/crates.io-index"
49 106
50 107 [[package]]
51 108 name = "hg-core"
52 109 version = "0.1.0"
53 110 dependencies = [
54 "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
55 "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
56 "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
111 "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
112 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
113 "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
57 114 "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
58 "rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
59 "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
115 "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
116 "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
117 "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
60 118 ]
61 119
62 120 [[package]]
@@ -65,7 +123,7 b' version = "0.1.0"'
65 123 dependencies = [
66 124 "cpython 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
67 125 "hg-core 0.1.0",
68 "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
126 "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
69 127 ]
70 128
71 129 [[package]]
@@ -73,36 +131,60 b' name = "hgdirectffi"'
73 131 version = "0.1.0"
74 132 dependencies = [
75 133 "hg-core 0.1.0",
76 "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
134 "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
77 135 ]
78 136
79 137 [[package]]
80 138 name = "lazy_static"
81 version = "1.3.0"
139 version = "1.4.0"
82 140 source = "registry+https://github.com/rust-lang/crates.io-index"
83 141
84 142 [[package]]
85 143 name = "libc"
86 version = "0.2.45"
144 version = "0.2.64"
87 145 source = "registry+https://github.com/rust-lang/crates.io-index"
88 146
89 147 [[package]]
90 148 name = "memchr"
91 version = "2.2.0"
149 version = "2.2.1"
150 source = "registry+https://github.com/rust-lang/crates.io-index"
151
152 [[package]]
153 name = "memoffset"
154 version = "0.5.1"
155 source = "registry+https://github.com/rust-lang/crates.io-index"
156 dependencies = [
157 "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
158 ]
159
160 [[package]]
161 name = "nodrop"
162 version = "0.1.14"
92 163 source = "registry+https://github.com/rust-lang/crates.io-index"
93 164
94 165 [[package]]
95 166 name = "num-traits"
96 version = "0.2.6"
167 version = "0.2.8"
97 168 source = "registry+https://github.com/rust-lang/crates.io-index"
169 dependencies = [
170 "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
171 ]
172
173 [[package]]
174 name = "num_cpus"
175 version = "1.10.1"
176 source = "registry+https://github.com/rust-lang/crates.io-index"
177 dependencies = [
178 "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
179 ]
98 180
99 181 [[package]]
100 182 name = "python27-sys"
101 183 version = "0.3.0"
102 184 source = "registry+https://github.com/rust-lang/crates.io-index"
103 185 dependencies = [
104 "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
105 "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
186 "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
187 "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
106 188 ]
107 189
108 190 [[package]]
@@ -110,8 +192,8 b' name = "python3-sys"'
110 192 version = "0.3.0"
111 193 source = "registry+https://github.com/rust-lang/crates.io-index"
112 194 dependencies = [
113 "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
114 "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
195 "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
196 "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
115 197 ]
116 198
117 199 [[package]]
@@ -119,17 +201,17 b' name = "rand"'
119 201 version = "0.6.5"
120 202 source = "registry+https://github.com/rust-lang/crates.io-index"
121 203 dependencies = [
122 "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
123 "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
204 "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
205 "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
124 206 "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
125 "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
207 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
126 208 "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
127 209 "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
128 "rand_jitter 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
129 "rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
130 "rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
210 "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
211 "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
212 "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
131 213 "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
132 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
214 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
133 215 ]
134 216
135 217 [[package]]
@@ -137,7 +219,7 b' name = "rand_chacha"'
137 219 version = "0.1.1"
138 220 source = "registry+https://github.com/rust-lang/crates.io-index"
139 221 dependencies = [
140 "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
222 "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
141 223 "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
142 224 ]
143 225
@@ -146,12 +228,12 b' name = "rand_core"'
146 228 version = "0.3.1"
147 229 source = "registry+https://github.com/rust-lang/crates.io-index"
148 230 dependencies = [
149 "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
231 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
150 232 ]
151 233
152 234 [[package]]
153 235 name = "rand_core"
154 version = "0.4.0"
236 version = "0.4.2"
155 237 source = "registry+https://github.com/rust-lang/crates.io-index"
156 238
157 239 [[package]]
@@ -172,34 +254,34 b' dependencies = ['
172 254
173 255 [[package]]
174 256 name = "rand_jitter"
175 version = "0.1.2"
257 version = "0.1.4"
176 258 source = "registry+https://github.com/rust-lang/crates.io-index"
177 259 dependencies = [
178 "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
179 "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
180 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
260 "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
261 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
262 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
181 263 ]
182 264
183 265 [[package]]
184 266 name = "rand_os"
185 version = "0.1.2"
267 version = "0.1.3"
186 268 source = "registry+https://github.com/rust-lang/crates.io-index"
187 269 dependencies = [
188 270 "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
189 "fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
190 "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
191 "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
271 "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
272 "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
273 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
192 274 "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
193 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
275 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
194 276 ]
195 277
196 278 [[package]]
197 279 name = "rand_pcg"
198 version = "0.1.1"
280 version = "0.1.2"
199 281 source = "registry+https://github.com/rust-lang/crates.io-index"
200 282 dependencies = [
201 "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
202 "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
283 "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
284 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
203 285 ]
204 286
205 287 [[package]]
@@ -211,6 +293,28 b' dependencies = ['
211 293 ]
212 294
213 295 [[package]]
296 name = "rayon"
297 version = "1.2.0"
298 source = "registry+https://github.com/rust-lang/crates.io-index"
299 dependencies = [
300 "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
301 "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
302 "rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
303 ]
304
305 [[package]]
306 name = "rayon-core"
307 version = "1.6.0"
308 source = "registry+https://github.com/rust-lang/crates.io-index"
309 dependencies = [
310 "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
311 "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
312 "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
313 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
314 "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
315 ]
316
317 [[package]]
214 318 name = "rdrand"
215 319 version = "0.4.0"
216 320 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -220,23 +324,19 b' dependencies = ['
220 324
221 325 [[package]]
222 326 name = "regex"
223 version = "1.1.0"
327 version = "1.3.1"
224 328 source = "registry+https://github.com/rust-lang/crates.io-index"
225 329 dependencies = [
226 "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
227 "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
228 "regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
330 "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
331 "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
332 "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
229 333 "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
230 "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
231 334 ]
232 335
233 336 [[package]]
234 337 name = "regex-syntax"
235 version = "0.6.4"
338 version = "0.6.12"
236 339 source = "registry+https://github.com/rust-lang/crates.io-index"
237 dependencies = [
238 "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
239 ]
240 340
241 341 [[package]]
242 342 name = "rustc_version"
@@ -247,6 +347,11 b' dependencies = ['
247 347 ]
248 348
249 349 [[package]]
350 name = "scopeguard"
351 version = "1.0.0"
352 source = "registry+https://github.com/rust-lang/crates.io-index"
353
354 [[package]]
250 355 name = "semver"
251 356 version = "0.9.0"
252 357 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -264,22 +369,12 b' name = "thread_local"'
264 369 version = "0.3.6"
265 370 source = "registry+https://github.com/rust-lang/crates.io-index"
266 371 dependencies = [
267 "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
372 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
268 373 ]
269 374
270 375 [[package]]
271 name = "ucd-util"
272 version = "0.1.3"
273 source = "registry+https://github.com/rust-lang/crates.io-index"
274
275 [[package]]
276 name = "utf8-ranges"
277 version = "1.0.2"
278 source = "registry+https://github.com/rust-lang/crates.io-index"
279
280 [[package]]
281 376 name = "winapi"
282 version = "0.3.6"
377 version = "0.3.8"
283 378 source = "registry+https://github.com/rust-lang/crates.io-index"
284 379 dependencies = [
285 380 "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -297,38 +392,49 b' version = "0.4.0"'
297 392 source = "registry+https://github.com/rust-lang/crates.io-index"
298 393
299 394 [metadata]
300 "checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e"
301 "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
302 "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
303 "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
395 "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"
396 "checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9"
397 "checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875"
398 "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
399 "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
400 "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
304 401 "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
305 402 "checksum cpython 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85532c648315aeb0829ad216a6a29aa3212cf9319bc7f6daf1404aa0bdd1485f"
306 "checksum fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81f7f8eb465745ea9b02e2704612a9946a59fa40572086c6fd49d6ddcf30bf31"
307 "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
308 "checksum libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2857ec59fadc0773853c664d2d18e7198e83883e7060b63c924cb077bd5c74"
309 "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39"
310 "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
403 "checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71"
404 "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9"
405 "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b"
406 "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"
407 "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
408 "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
409 "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
410 "checksum libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)" = "74dfca3d9957906e8d1e6a0b641dc9a59848e793f1da2165889fd4f62d10d79c"
411 "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
412 "checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f"
413 "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
414 "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32"
415 "checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273"
311 416 "checksum python27-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "372555e88a6bc8109eb641380240dc8d25a128fc48363ec9075664daadffdd5b"
312 417 "checksum python3-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f3a8ebed3f1201fda179f3960609dbbc10cd8c75e9f2afcb03788278f367d8ea"
313 418 "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
314 419 "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
315 420 "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
316 "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
421 "checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
317 422 "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
318 423 "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
319 "checksum rand_jitter 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "080723c6145e37503a2224f801f252e14ac5531cb450f4502698542d188cb3c0"
320 "checksum rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b7c690732391ae0abafced5015ffb53656abfaec61b342290e5eb56b286a679d"
321 "checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05"
424 "checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
425 "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
426 "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
322 427 "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
428 "checksum rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "83a27732a533a1be0a0035a111fe76db89ad312f6f0347004c220c57f209a123"
429 "checksum rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "98dcf634205083b17d0861252431eb2acbfb698ab7478a2d20de07954f47ec7b"
323 430 "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
324 "checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f"
325 "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1"
431 "checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd"
432 "checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716"
326 433 "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
434 "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
327 435 "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
328 436 "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
329 437 "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
330 "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
331 "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737"
332 "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
438 "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
333 439 "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
334 440 "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
@@ -15,3 +15,4 b' memchr = "2.2.0"'
15 15 rand = "0.6.5"
16 16 rand_pcg = "0.1.1"
17 17 regex = "1.1.0"
18 rayon = "1.2.0"
@@ -13,6 +13,7 b' use std::convert::TryFrom;'
13 13 pub mod dirs_multiset;
14 14 pub mod dirstate_map;
15 15 pub mod parsers;
16 pub mod status;
16 17
17 18 #[derive(Debug, PartialEq, Clone)]
18 19 pub struct DirstateParents {
@@ -12,6 +12,7 b' pub use dirstate::{'
12 12 dirs_multiset::{DirsMultiset, DirsMultisetIter},
13 13 dirstate_map::DirstateMap,
14 14 parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE},
15 status::status,
15 16 CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState,
16 17 StateMap, StateMapIter,
17 18 };
@@ -12,6 +12,7 b''
12 12 use crate::utils::hg_path::{HgPath, HgPathBuf};
13 13 use std::iter::FusedIterator;
14 14
15 use std::fs::Metadata;
15 16 use std::path::Path;
16 17
17 18 pub fn get_path_from_bytes(bytes: &[u8]) -> &Path {
@@ -76,6 +77,32 b' pub fn normalize_case(path: &HgPath) -> '
76 77 path.to_ascii_lowercase()
77 78 }
78 79
80 #[derive(Eq, PartialEq, Ord, PartialOrd, Copy, Clone)]
81 pub struct HgMetadata {
82 pub st_dev: u64,
83 pub st_mode: u32,
84 pub st_nlink: u64,
85 pub st_size: u64,
86 pub st_mtime: i64,
87 pub st_ctime: i64,
88 }
89
90 // TODO support other plaforms
91 #[cfg(unix)]
92 impl HgMetadata {
93 pub fn from_metadata(metadata: Metadata) -> Self {
94 use std::os::unix::fs::MetadataExt;
95 Self {
96 st_dev: metadata.dev(),
97 st_mode: metadata.mode(),
98 st_nlink: metadata.nlink(),
99 st_size: metadata.size(),
100 st_mtime: metadata.mtime(),
101 st_ctime: metadata.ctime(),
102 }
103 }
104 }
105
79 106 #[cfg(test)]
80 107 mod tests {
81 108 use super::*;
General Comments 0
You need to be logged in to leave comments. Login now