##// END OF EJS Templates
rust-dirs-multiset: improve temporary error message...
Raphaël Gomès -
r44765:934a7969 default
parent child Browse files
Show More
@@ -12,7 +12,7 b' use crate::{'
12 dirstate::EntryState,
12 dirstate::EntryState,
13 utils::{
13 utils::{
14 files,
14 files,
15 hg_path::{HgPath, HgPathBuf},
15 hg_path::{HgPath, HgPathBuf, HgPathError},
16 },
16 },
17 DirstateEntry, DirstateMapError, FastHashMap,
17 DirstateEntry, DirstateMapError, FastHashMap,
18 };
18 };
@@ -78,7 +78,14 b' impl DirsMultiset {'
78 if subpath.as_bytes().last() == Some(&b'/') {
78 if subpath.as_bytes().last() == Some(&b'/') {
79 // TODO Remove this once PathAuditor is certified
79 // TODO Remove this once PathAuditor is certified
80 // as the only entrypoint for path data
80 // as the only entrypoint for path data
81 return Err(DirstateMapError::ConsecutiveSlashes);
81 let second_slash_index = subpath.len() - 1;
82
83 return Err(DirstateMapError::InvalidPath(
84 HgPathError::ConsecutiveSlashes {
85 bytes: path.as_ref().as_bytes().to_owned(),
86 second_slash_index,
87 },
88 ));
82 }
89 }
83 if let Some(val) = self.inner.get_mut(subpath) {
90 if let Some(val) = self.inner.get_mut(subpath) {
84 *val += 1;
91 *val += 1;
@@ -23,7 +23,7 b' pub mod revlog;'
23 pub use revlog::*;
23 pub use revlog::*;
24 pub mod utils;
24 pub mod utils;
25
25
26 use crate::utils::hg_path::HgPathBuf;
26 use crate::utils::hg_path::{HgPathBuf, HgPathError};
27 pub use filepatterns::{
27 pub use filepatterns::{
28 build_single_regex, read_pattern_file, PatternSyntax, PatternTuple,
28 build_single_regex, read_pattern_file, PatternSyntax, PatternTuple,
29 };
29 };
@@ -79,18 +79,17 b' impl From<std::io::Error> for DirstatePa'
79 pub enum DirstateMapError {
79 pub enum DirstateMapError {
80 PathNotFound(HgPathBuf),
80 PathNotFound(HgPathBuf),
81 EmptyPath,
81 EmptyPath,
82 ConsecutiveSlashes,
82 InvalidPath(HgPathError),
83 }
83 }
84
84
85 impl ToString for DirstateMapError {
85 impl ToString for DirstateMapError {
86 fn to_string(&self) -> String {
86 fn to_string(&self) -> String {
87 use crate::DirstateMapError::*;
88 match self {
87 match self {
89 PathNotFound(_) => "expected a value, found none".to_string(),
88 DirstateMapError::PathNotFound(_) => {
90 EmptyPath => "Overflow in dirstate.".to_string(),
89 "expected a value, found none".to_string()
91 ConsecutiveSlashes => {
92 "found invalid consecutive slashes in path".to_string()
93 }
90 }
91 DirstateMapError::EmptyPath => "Overflow in dirstate.".to_string(),
92 DirstateMapError::InvalidPath(e) => e.to_string(),
94 }
93 }
95 }
94 }
96 }
95 }
General Comments 0
You need to be logged in to leave comments. Login now