##// END OF EJS Templates
rust-status: add missing variants to `Dispatch` enum...
Raphaël Gomès -
r45013:61709b84 default
parent child Browse files
Show More
@@ -25,6 +25,25 b' use std::collections::HashSet;'
25 25 use std::fs::{read_dir, DirEntry};
26 26 use std::path::Path;
27 27
28 /// Wrong type of file from a `BadMatch`
29 /// Note: a lot of those don't exist on all platforms.
30 #[derive(Debug)]
31 pub enum BadType {
32 CharacterDevice,
33 BlockDevice,
34 FIFO,
35 Socket,
36 Directory,
37 Unknown,
38 }
39
40 /// Was explicitly matched but cannot be found/accessed
41 #[derive(Debug)]
42 pub enum BadMatch {
43 OsError(i32),
44 BadType(BadType),
45 }
46
28 47 /// Marker enum used to dispatch new status entries into the right collections.
29 48 /// Is similar to `crate::EntryState`, but represents the transient state of
30 49 /// entries during the lifetime of a command.
@@ -36,6 +55,16 b' enum Dispatch {'
36 55 Deleted,
37 56 Clean,
38 57 Unknown,
58 Ignored,
59 /// Empty dispatch, the file is not worth listing
60 None,
61 /// Was explicitly matched but cannot be found/accessed
62 Bad(BadMatch),
63 Directory {
64 /// True if the directory used to be a file in the dmap so we can say
65 /// that it's been removed.
66 was_file: bool,
67 },
39 68 }
40 69
41 70 type IoResult<T> = std::io::Result<T>;
@@ -261,8 +290,9 b" pub struct DirstateStatus<'a> {"
261 290 pub removed: Vec<&'a HgPath>,
262 291 pub deleted: Vec<&'a HgPath>,
263 292 pub clean: Vec<&'a HgPath>,
264 /* TODO ignored
265 * TODO unknown */
293 pub ignored: Vec<&'a HgPath>,
294 pub unknown: Vec<&'a HgPath>,
295 pub bad: Vec<(&'a HgPath, BadMatch)>,
266 296 }
267 297
268 298 fn build_response<'a>(
@@ -274,17 +304,24 b" fn build_response<'a>("
274 304 let mut removed = vec![];
275 305 let mut deleted = vec![];
276 306 let mut clean = vec![];
307 let mut ignored = vec![];
308 let mut unknown = vec![];
309 let mut bad = vec![];
277 310
278 311 for res in results.into_iter() {
279 312 let (filename, dispatch) = res?;
280 313 match dispatch {
281 Dispatch::Unknown => {}
314 Dispatch::Unknown => unknown.push(filename),
282 315 Dispatch::Unsure => lookup.push(filename),
283 316 Dispatch::Modified => modified.push(filename),
284 317 Dispatch::Added => added.push(filename),
285 318 Dispatch::Removed => removed.push(filename),
286 319 Dispatch::Deleted => deleted.push(filename),
287 320 Dispatch::Clean => clean.push(filename),
321 Dispatch::Ignored => ignored.push(filename),
322 Dispatch::None => {}
323 Dispatch::Bad(reason) => bad.push((filename, reason)),
324 Dispatch::Directory { .. } => {}
288 325 }
289 326 }
290 327
@@ -296,6 +333,9 b" fn build_response<'a>("
296 333 removed,
297 334 deleted,
298 335 clean,
336 ignored,
337 unknown,
338 bad,
299 339 },
300 340 ))
301 341 }
General Comments 0
You need to be logged in to leave comments. Login now