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