diff rust/hg-core/src/repo.rs @ 46740:97ac588b6d9e

rhg: Don?t make repository path absolute too early Some error messages want to include a relative path, which affects the output of some tests. Differential Revision: https://phab.mercurial-scm.org/D10138
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 08 Mar 2021 08:35:43 +0100
parents 12d59eec7f1d
children 25e3dac511f0
line wrap: on
line diff
--- a/rust/hg-core/src/repo.rs	Fri Mar 05 13:28:49 2021 +0100
+++ b/rust/hg-core/src/repo.rs	Mon Mar 08 08:35:43 2021 +0100
@@ -2,7 +2,7 @@
 use crate::errors::{HgError, IoErrorContext, IoResultExt};
 use crate::requirements;
 use crate::utils::files::get_path_from_bytes;
-use crate::utils::{current_dir, SliceExt};
+use crate::utils::SliceExt;
 use memmap::{Mmap, MmapOptions};
 use std::collections::HashSet;
 use std::path::{Path, PathBuf};
@@ -56,12 +56,9 @@
         explicit_path: Option<&Path>,
     ) -> Result<Self, RepoError> {
         if let Some(root) = explicit_path {
-            // Having an absolute path isn’t necessary here but can help code
-            // elsewhere
-            let absolute_root = current_dir()?.join(root);
-            if absolute_root.join(".hg").is_dir() {
-                Self::new_at_path(absolute_root, config)
-            } else if absolute_root.is_file() {
+            if root.join(".hg").is_dir() {
+                Self::new_at_path(root.to_owned(), config)
+            } else if root.is_file() {
                 Err(HgError::unsupported("bundle repository").into())
             } else {
                 Err(RepoError::NotFound {