comparison rust/hg-core/src/repo.rs @ 47977:696abab107b4

rust: Generalize the `trim_end_newlines` utility of byte strings … into `trim_end_matches` that takes a callack. Also add `trim_start_matches`. Differential Revision: https://phab.mercurial-scm.org/D11388
author Simon Sapin <simon.sapin@octobus.net>
date Fri, 03 Sep 2021 16:37:20 +0200
parents cf5f8da2244c
children 9cd35c8c6044
comparison
equal deleted inserted replaced
47976:83f0e93ec34b 47977:696abab107b4
125 if !shared { 125 if !shared {
126 store_path = dot_hg.join("store"); 126 store_path = dot_hg.join("store");
127 } else { 127 } else {
128 let bytes = hg_vfs.read("sharedpath")?; 128 let bytes = hg_vfs.read("sharedpath")?;
129 let mut shared_path = 129 let mut shared_path =
130 get_path_from_bytes(bytes.trim_end_newlines()).to_owned(); 130 get_path_from_bytes(bytes.trim_end_matches(|b| b == b'\n'))
131 .to_owned();
131 if relative { 132 if relative {
132 shared_path = dot_hg.join(shared_path) 133 shared_path = dot_hg.join(shared_path)
133 } 134 }
134 if !is_dir(&shared_path)? { 135 if !is_dir(&shared_path)? {
135 return Err(HgError::corrupted(format!( 136 return Err(HgError::corrupted(format!(