comparison rust/hg-core/src/dirstate/dirs_multiset.rs @ 43788:1fe2e574616e

rust-dirs: address failing tests for `dirs` impl with a temporary fix https://phab.mercurial-scm.org/D7252 (5d40317d42b7083b49467502549e25f144888cb3) introduced a regression in Rust tests. This is a temporary fix that replicates the behavior of the C and Python impl, pending the resolution of the discussion (in the phabricator link) about how we actually want to solve this problem. Differential Revision: https://phab.mercurial-scm.org/D7503
author Raphaël Gomès <rgomes@octobus.net>
date Fri, 22 Nov 2019 10:39:05 +0100
parents 7a01778bc7b7
children 5ac243a92e37
comparison
equal deleted inserted replaced
43787:be8552f25cab 43788:1fe2e574616e
63 } 63 }
64 64
65 /// Increases the count of deepest directory contained in the path. 65 /// Increases the count of deepest directory contained in the path.
66 /// 66 ///
67 /// If the directory is not yet in the map, adds its parents. 67 /// If the directory is not yet in the map, adds its parents.
68 pub fn add_path(&mut self, path: &HgPath) { 68 pub fn add_path(&mut self, path: &HgPath) -> Result<(), DirstateMapError> {
69 for subpath in files::find_dirs(path) { 69 for subpath in files::find_dirs(path) {
70 if subpath.as_bytes().last() == Some(&b'/') {
71 // TODO Remove this once PathAuditor is certified
72 // as the only entrypoint for path data
73 return Err(DirstateMapError::ConsecutiveSlashes);
74 }
70 if let Some(val) = self.inner.get_mut(subpath) { 75 if let Some(val) = self.inner.get_mut(subpath) {
71 *val += 1; 76 *val += 1;
72 break; 77 break;
73 } 78 }
74 self.inner.insert(subpath.to_owned(), 1); 79 self.inner.insert(subpath.to_owned(), 1);
75 } 80 }
81 Ok(())
76 } 82 }
77 83
78 /// Decreases the count of deepest directory contained in the path. 84 /// Decreases the count of deepest directory contained in the path.
79 /// 85 ///
80 /// If it is the only reference, decreases all parents until one is 86 /// If it is the only reference, decreases all parents until one is