Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/utils.rs @ 46513: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 |
line wrap: on
line diff
--- a/rust/hg-core/src/utils.rs Thu Jan 28 19:21:57 2021 +0100 +++ b/rust/hg-core/src/utils.rs Thu Jan 28 19:13:55 2021 +0100 @@ -7,6 +7,7 @@ //! Contains useful functions, traits, structs, etc. for use in core. +use crate::errors::{HgError, IoErrorContext}; use crate::utils::hg_path::HgPath; use std::{io::Write, ops::Deref}; @@ -176,3 +177,10 @@ None } } + +pub fn current_dir() -> Result<std::path::PathBuf, HgError> { + std::env::current_dir().map_err(|error| HgError::IoError { + error, + context: IoErrorContext::CurrentDir, + }) +}