Patchwork D7921: rust-dirs-multiset: improve temporary error message

login
register
mail settings
Submitter phabricator
Date Feb. 7, 2020, 9:38 p.m.
Message ID <1dd5a5e5f47aa8b70556942b2161a37b@localhost.localdomain>
Download mbox | patch
Permalink /patch/45036/
State Not Applicable
Headers show

Comments

phabricator - Feb. 7, 2020, 9:38 p.m.
Closed by commit rHGa5c7d6cdaa2e: rust-dirs-multiset: improve temporary error message (authored by Alphare).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7921?vs=19548&id=20002

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7921/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7921

AFFECTED FILES
  rust/hg-core/src/dirstate/dirs_multiset.rs
  rust/hg-core/src/lib.rs

CHANGE DETAILS




To: Alphare, #hg-reviewers, kevincox, pulkit
Cc: martinvonz, durin42, kevincox, mercurial-devel

Patch

diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs
--- a/rust/hg-core/src/lib.rs
+++ b/rust/hg-core/src/lib.rs
@@ -79,18 +79,17 @@ 
 pub enum DirstateMapError {
     PathNotFound(HgPathBuf),
     EmptyPath,
-    ConsecutiveSlashes,
+    InvalidPath(HgPathError),
 }
 
 impl ToString for DirstateMapError {
     fn to_string(&self) -> String {
-        use crate::DirstateMapError::*;
         match self {
-            PathNotFound(_) => "expected a value, found none".to_string(),
-            EmptyPath => "Overflow in dirstate.".to_string(),
-            ConsecutiveSlashes => {
-                "found invalid consecutive slashes in path".to_string()
+            DirstateMapError::PathNotFound(_) => {
+                "expected a value, found none".to_string()
             }
+            DirstateMapError::EmptyPath => "Overflow in dirstate.".to_string(),
+            DirstateMapError::InvalidPath(e) => e.to_string(),
         }
     }
 }
diff --git a/rust/hg-core/src/dirstate/dirs_multiset.rs b/rust/hg-core/src/dirstate/dirs_multiset.rs
--- a/rust/hg-core/src/dirstate/dirs_multiset.rs
+++ b/rust/hg-core/src/dirstate/dirs_multiset.rs
@@ -12,7 +12,7 @@ 
     dirstate::EntryState,
     utils::{
         files,
-        hg_path::{HgPath, HgPathBuf},
+        hg_path::{HgPath, HgPathBuf, HgPathError},
     },
     DirstateEntry, DirstateMapError, FastHashMap,
 };
@@ -78,7 +78,14 @@ 
             if subpath.as_bytes().last() == Some(&b'/') {
                 // TODO Remove this once PathAuditor is certified
                 // as the only entrypoint for path data
-                return Err(DirstateMapError::ConsecutiveSlashes);
+                let second_slash_index = subpath.len() - 1;
+
+                return Err(DirstateMapError::InvalidPath(
+                    HgPathError::ConsecutiveSlashes {
+                        bytes: path.as_ref().as_bytes().to_owned(),
+                        second_slash_index,
+                    },
+                ));
             }
             if let Some(val) = self.inner.get_mut(subpath) {
                 *val += 1;