Show More
@@ -62,7 +62,7 b' impl DirsMultiset {' | |||||
62 | /// Initializes the multiset from a manifest. |
|
62 | /// Initializes the multiset from a manifest. | |
63 | pub fn from_manifest( |
|
63 | pub fn from_manifest( | |
64 | manifest: &[impl AsRef<HgPath>], |
|
64 | manifest: &[impl AsRef<HgPath>], | |
65 |
) -> Result<Self, |
|
65 | ) -> Result<Self, HgPathError> { | |
66 | let mut multiset = DirsMultiset { |
|
66 | let mut multiset = DirsMultiset { | |
67 | inner: FastHashMap::default(), |
|
67 | inner: FastHashMap::default(), | |
68 | }; |
|
68 | }; | |
@@ -80,19 +80,17 b' impl DirsMultiset {' | |||||
80 | pub fn add_path( |
|
80 | pub fn add_path( | |
81 | &mut self, |
|
81 | &mut self, | |
82 | path: impl AsRef<HgPath>, |
|
82 | path: impl AsRef<HgPath>, | |
83 |
) -> Result<(), |
|
83 | ) -> Result<(), HgPathError> { | |
84 | for subpath in files::find_dirs(path.as_ref()) { |
|
84 | for subpath in files::find_dirs(path.as_ref()) { | |
85 | if subpath.as_bytes().last() == Some(&b'/') { |
|
85 | if subpath.as_bytes().last() == Some(&b'/') { | |
86 | // TODO Remove this once PathAuditor is certified |
|
86 | // TODO Remove this once PathAuditor is certified | |
87 | // as the only entrypoint for path data |
|
87 | // as the only entrypoint for path data | |
88 | let second_slash_index = subpath.len() - 1; |
|
88 | let second_slash_index = subpath.len() - 1; | |
89 |
|
89 | |||
90 |
return Err( |
|
90 | return Err(HgPathError::ConsecutiveSlashes { | |
91 | HgPathError::ConsecutiveSlashes { |
|
91 | bytes: path.as_ref().as_bytes().to_owned(), | |
92 | bytes: path.as_ref().as_bytes().to_owned(), |
|
92 | second_slash_index, | |
93 | second_slash_index, |
|
93 | }); | |
94 | }, |
|
|||
95 | )); |
|
|||
96 | } |
|
94 | } | |
97 | if let Some(val) = self.inner.get_mut(subpath) { |
|
95 | if let Some(val) = self.inner.get_mut(subpath) { | |
98 | *val += 1; |
|
96 | *val += 1; |
@@ -66,6 +66,12 b' pub enum DirstateMapError {' | |||||
66 | InvalidPath(HgPathError), |
|
66 | InvalidPath(HgPathError), | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
|
69 | impl From<HgPathError> for DirstateMapError { | |||
|
70 | fn from(error: HgPathError) -> Self { | |||
|
71 | Self::InvalidPath(error) | |||
|
72 | } | |||
|
73 | } | |||
|
74 | ||||
69 | impl fmt::Display for DirstateMapError { |
|
75 | impl fmt::Display for DirstateMapError { | |
70 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
|
76 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | |
71 | match self { |
|
77 | match self { | |
@@ -83,6 +89,12 b' pub enum DirstateError {' | |||||
83 | Common(errors::HgError), |
|
89 | Common(errors::HgError), | |
84 | } |
|
90 | } | |
85 |
|
91 | |||
|
92 | impl From<HgPathError> for DirstateError { | |||
|
93 | fn from(error: HgPathError) -> Self { | |||
|
94 | Self::Map(DirstateMapError::InvalidPath(error)) | |||
|
95 | } | |||
|
96 | } | |||
|
97 | ||||
86 | impl fmt::Display for DirstateError { |
|
98 | impl fmt::Display for DirstateError { | |
87 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
|
99 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | |
88 | match self { |
|
100 | match self { |
@@ -15,11 +15,10 b' use crate::{' | |||||
15 | }, |
|
15 | }, | |
16 | utils::{ |
|
16 | utils::{ | |
17 | files::find_dirs, |
|
17 | files::find_dirs, | |
18 | hg_path::{HgPath, HgPathBuf}, |
|
18 | hg_path::{HgPath, HgPathBuf, HgPathError}, | |
19 | Escaped, |
|
19 | Escaped, | |
20 | }, |
|
20 | }, | |
21 |
DirsMultiset |
|
21 | DirsMultiset, FastHashMap, IgnorePattern, PatternError, PatternSyntax, | |
22 | PatternSyntax, |
|
|||
23 | }; |
|
22 | }; | |
24 |
|
23 | |||
25 | use crate::dirstate::status::IgnoreFnType; |
|
24 | use crate::dirstate::status::IgnoreFnType; | |
@@ -177,7 +176,7 b' pub struct FileMatcher {' | |||||
177 | } |
|
176 | } | |
178 |
|
177 | |||
179 | impl FileMatcher { |
|
178 | impl FileMatcher { | |
180 |
pub fn new(files: Vec<HgPathBuf>) -> Result<Self, |
|
179 | pub fn new(files: Vec<HgPathBuf>) -> Result<Self, HgPathError> { | |
181 | let dirs = DirsMultiset::from_manifest(&files)?; |
|
180 | let dirs = DirsMultiset::from_manifest(&files)?; | |
182 | Ok(Self { |
|
181 | Ok(Self { | |
183 | files: HashSet::from_iter(files.into_iter()), |
|
182 | files: HashSet::from_iter(files.into_iter()), | |
@@ -760,20 +759,12 b' fn roots_dirs_and_parents(' | |||||
760 | let mut parents = HashSet::new(); |
|
759 | let mut parents = HashSet::new(); | |
761 |
|
760 | |||
762 | parents.extend( |
|
761 | parents.extend( | |
763 | DirsMultiset::from_manifest(&dirs) |
|
762 | DirsMultiset::from_manifest(&dirs)? | |
764 | .map_err(|e| match e { |
|
|||
765 | DirstateMapError::InvalidPath(e) => e, |
|
|||
766 | _ => unreachable!(), |
|
|||
767 | })? |
|
|||
768 | .iter() |
|
763 | .iter() | |
769 | .map(ToOwned::to_owned), |
|
764 | .map(ToOwned::to_owned), | |
770 | ); |
|
765 | ); | |
771 | parents.extend( |
|
766 | parents.extend( | |
772 | DirsMultiset::from_manifest(&roots) |
|
767 | DirsMultiset::from_manifest(&roots)? | |
773 | .map_err(|e| match e { |
|
|||
774 | DirstateMapError::InvalidPath(e) => e, |
|
|||
775 | _ => unreachable!(), |
|
|||
776 | })? |
|
|||
777 | .iter() |
|
768 | .iter() | |
778 | .map(ToOwned::to_owned), |
|
769 | .map(ToOwned::to_owned), | |
779 | ); |
|
770 | ); |
General Comments 0
You need to be logged in to leave comments.
Login now