##// 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 use std::fs::{read_dir, DirEntry};
25 use std::fs::{read_dir, DirEntry};
26 use std::path::Path;
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 /// Marker enum used to dispatch new status entries into the right collections.
47 /// Marker enum used to dispatch new status entries into the right collections.
29 /// Is similar to `crate::EntryState`, but represents the transient state of
48 /// Is similar to `crate::EntryState`, but represents the transient state of
30 /// entries during the lifetime of a command.
49 /// entries during the lifetime of a command.
@@ -36,6 +55,16 b' enum Dispatch {'
36 Deleted,
55 Deleted,
37 Clean,
56 Clean,
38 Unknown,
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 type IoResult<T> = std::io::Result<T>;
70 type IoResult<T> = std::io::Result<T>;
@@ -261,8 +290,9 b" pub struct DirstateStatus<'a> {"
261 pub removed: Vec<&'a HgPath>,
290 pub removed: Vec<&'a HgPath>,
262 pub deleted: Vec<&'a HgPath>,
291 pub deleted: Vec<&'a HgPath>,
263 pub clean: Vec<&'a HgPath>,
292 pub clean: Vec<&'a HgPath>,
264 /* TODO ignored
293 pub ignored: Vec<&'a HgPath>,
265 * TODO unknown */
294 pub unknown: Vec<&'a HgPath>,
295 pub bad: Vec<(&'a HgPath, BadMatch)>,
266 }
296 }
267
297
268 fn build_response<'a>(
298 fn build_response<'a>(
@@ -274,17 +304,24 b" fn build_response<'a>("
274 let mut removed = vec![];
304 let mut removed = vec![];
275 let mut deleted = vec![];
305 let mut deleted = vec![];
276 let mut clean = vec![];
306 let mut clean = vec![];
307 let mut ignored = vec![];
308 let mut unknown = vec![];
309 let mut bad = vec![];
277
310
278 for res in results.into_iter() {
311 for res in results.into_iter() {
279 let (filename, dispatch) = res?;
312 let (filename, dispatch) = res?;
280 match dispatch {
313 match dispatch {
281 Dispatch::Unknown => {}
314 Dispatch::Unknown => unknown.push(filename),
282 Dispatch::Unsure => lookup.push(filename),
315 Dispatch::Unsure => lookup.push(filename),
283 Dispatch::Modified => modified.push(filename),
316 Dispatch::Modified => modified.push(filename),
284 Dispatch::Added => added.push(filename),
317 Dispatch::Added => added.push(filename),
285 Dispatch::Removed => removed.push(filename),
318 Dispatch::Removed => removed.push(filename),
286 Dispatch::Deleted => deleted.push(filename),
319 Dispatch::Deleted => deleted.push(filename),
287 Dispatch::Clean => clean.push(filename),
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 removed,
333 removed,
297 deleted,
334 deleted,
298 clean,
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