equal
deleted
inserted
replaced
38 None => vec![], |
38 None => vec![], |
39 }; |
39 }; |
40 |
40 |
41 let repo = invocation.repo?; |
41 let repo = invocation.repo?; |
42 let cwd = hg::utils::current_dir()?; |
42 let cwd = hg::utils::current_dir()?; |
|
43 let working_directory = repo.working_directory_path(); |
|
44 let working_directory = cwd.join(working_directory); // Make it absolute |
43 |
45 |
44 let mut files = vec![]; |
46 let mut files = vec![]; |
45 for file in file_args.iter() { |
47 for file in file_args.iter() { |
46 // TODO: actually normalize `..` path segments etc? |
48 // TODO: actually normalize `..` path segments etc? |
47 let normalized = cwd.join(&file); |
49 let normalized = cwd.join(&file); |
48 let stripped = normalized |
50 let stripped = normalized |
49 .strip_prefix(&repo.working_directory_path()) |
51 .strip_prefix(&working_directory) |
50 // TODO: error message for path arguments outside of the repo |
52 // TODO: error message for path arguments outside of the repo |
51 .map_err(|_| CommandError::abort(""))?; |
53 .map_err(|_| CommandError::abort(""))?; |
52 let hg_file = HgPathBuf::try_from(stripped.to_path_buf()) |
54 let hg_file = HgPathBuf::try_from(stripped.to_path_buf()) |
53 .map_err(|e| CommandError::abort(e.to_string()))?; |
55 .map_err(|e| CommandError::abort(e.to_string()))?; |
54 files.push(hg_file); |
56 files.push(hg_file); |