Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/utils.rs @ 46445:ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Differential Revision: https://phab.mercurial-scm.org/D9905
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Thu, 28 Jan 2021 19:13:55 +0100 |
parents | 9eb07ab3f2d4 |
children | 2845892dd489 |
comparison
equal
deleted
inserted
replaced
46444:6c778d20c8c2 | 46445:ca3f73cc3cf4 |
---|---|
5 // This software may be used and distributed according to the terms of the | 5 // This software may be used and distributed according to the terms of the |
6 // GNU General Public License version 2 or any later version. | 6 // GNU General Public License version 2 or any later version. |
7 | 7 |
8 //! Contains useful functions, traits, structs, etc. for use in core. | 8 //! Contains useful functions, traits, structs, etc. for use in core. |
9 | 9 |
10 use crate::errors::{HgError, IoErrorContext}; | |
10 use crate::utils::hg_path::HgPath; | 11 use crate::utils::hg_path::HgPath; |
11 use std::{io::Write, ops::Deref}; | 12 use std::{io::Write, ops::Deref}; |
12 | 13 |
13 pub mod files; | 14 pub mod files; |
14 pub mod hg_path; | 15 pub mod hg_path; |
174 Some(&s[..s.len() - suffix.len()]) | 175 Some(&s[..s.len() - suffix.len()]) |
175 } else { | 176 } else { |
176 None | 177 None |
177 } | 178 } |
178 } | 179 } |
180 | |
181 pub fn current_dir() -> Result<std::path::PathBuf, HgError> { | |
182 std::env::current_dir().map_err(|error| HgError::IoError { | |
183 error, | |
184 context: IoErrorContext::CurrentDir, | |
185 }) | |
186 } |