Show More
@@ -1,8 +1,8 b'' | |||
|
1 | 1 | use crate::config::{Config, ConfigError, ConfigParseError}; |
|
2 | 2 | use crate::errors::{HgError, IoErrorContext, IoResultExt}; |
|
3 | 3 | use crate::requirements; |
|
4 | use crate::utils::current_dir; | |
|
5 | 4 | use crate::utils::files::get_path_from_bytes; |
|
5 | use crate::utils::{current_dir, SliceExt}; | |
|
6 | 6 | use memmap::{Mmap, MmapOptions}; |
|
7 | 7 | use std::collections::HashSet; |
|
8 | 8 | use std::path::{Path, PathBuf}; |
@@ -118,7 +118,8 b' impl Repo {' | |||
|
118 | 118 | store_path = dot_hg.join("store"); |
|
119 | 119 | } else { |
|
120 | 120 | let bytes = hg_vfs.read("sharedpath")?; |
|
121 |
let mut shared_path = |
|
|
121 | let mut shared_path = | |
|
122 | get_path_from_bytes(bytes.trim_end_newlines()).to_owned(); | |
|
122 | 123 | if relative { |
|
123 | 124 | shared_path = dot_hg.join(shared_path) |
|
124 | 125 | } |
@@ -67,6 +67,7 b' where' | |||
|
67 | 67 | } |
|
68 | 68 | |
|
69 | 69 | pub trait SliceExt { |
|
70 | fn trim_end_newlines(&self) -> &Self; | |
|
70 | 71 | fn trim_end(&self) -> &Self; |
|
71 | 72 | fn trim_start(&self) -> &Self; |
|
72 | 73 | fn trim(&self) -> &Self; |
@@ -80,6 +81,13 b' fn is_not_whitespace(c: &u8) -> bool {' | |||
|
80 | 81 | } |
|
81 | 82 | |
|
82 | 83 | impl SliceExt for [u8] { |
|
84 | fn trim_end_newlines(&self) -> &[u8] { | |
|
85 | if let Some(last) = self.iter().rposition(|&byte| byte != b'\n') { | |
|
86 | &self[..=last] | |
|
87 | } else { | |
|
88 | &[] | |
|
89 | } | |
|
90 | } | |
|
83 | 91 | fn trim_end(&self) -> &[u8] { |
|
84 | 92 | if let Some(last) = self.iter().rposition(is_not_whitespace) { |
|
85 | 93 | &self[..=last] |
General Comments 0
You need to be logged in to leave comments.
Login now