##// END OF EJS Templates
rhg: add error message for paths outside the repository when cwd != root...
Raphaël Gomès -
r50270:044e42ae stable
parent child Browse files
Show More
@@ -67,10 +67,19 b' pub fn run(invocation: &crate::CliInvoca'
67 let message = "`..` or `.` path segment";
67 let message = "`..` or `.` path segment";
68 return Err(CommandError::unsupported(message));
68 return Err(CommandError::unsupported(message));
69 }
69 }
70 let relative_path = working_directory
71 .strip_prefix(&cwd)
72 .unwrap_or(&working_directory);
70 let stripped = normalized
73 let stripped = normalized
71 .strip_prefix(&working_directory)
74 .strip_prefix(&working_directory)
72 // TODO: error message for path arguments outside of the repo
75 .map_err(|_| {
73 .map_err(|_| CommandError::abort(""))?;
76 CommandError::abort(format!(
77 "abort: {} not under root '{}'\n(consider using '--cwd {}')",
78 file,
79 working_directory.display(),
80 relative_path.display(),
81 ))
82 })?;
74 let hg_file = HgPathBuf::try_from(stripped.to_path_buf())
83 let hg_file = HgPathBuf::try_from(stripped.to_path_buf())
75 .map_err(|e| CommandError::abort(e.to_string()))?;
84 .map_err(|e| CommandError::abort(e.to_string()))?;
76 files.push(hg_file);
85 files.push(hg_file);
General Comments 0
You need to be logged in to leave comments. Login now