equal
deleted
inserted
replaced
12 List tracked files. |
12 List tracked files. |
13 |
13 |
14 Returns 0 on success. |
14 Returns 0 on success. |
15 "; |
15 "; |
16 |
16 |
17 pub fn args() -> clap::App<'static, 'static> { |
17 pub fn args() -> clap::Command { |
18 clap::SubCommand::with_name("files") |
18 clap::command!("files") |
19 .arg( |
19 .arg( |
20 Arg::with_name("rev") |
20 Arg::new("rev") |
21 .help("search the repository as it is in REV") |
21 .help("search the repository as it is in REV") |
22 .short("-r") |
22 .short('r') |
23 .long("--revision") |
23 .long("revision") |
24 .value_name("REV") |
24 .value_name("REV"), |
25 .takes_value(true), |
|
26 ) |
25 ) |
27 .about(HELP_TEXT) |
26 .about(HELP_TEXT) |
28 } |
27 } |
29 |
28 |
30 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
29 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
33 return Err(CommandError::unsupported( |
32 return Err(CommandError::unsupported( |
34 "non-default ui.relative-paths", |
33 "non-default ui.relative-paths", |
35 )); |
34 )); |
36 } |
35 } |
37 |
36 |
38 let rev = invocation.subcommand_args.value_of("rev"); |
37 let rev = invocation.subcommand_args.get_one::<String>("rev"); |
39 |
38 |
40 let repo = invocation.repo?; |
39 let repo = invocation.repo?; |
41 |
40 |
42 // It seems better if this check is removed: this would correspond to |
41 // It seems better if this check is removed: this would correspond to |
43 // automatically enabling the extension if the repo requires it. |
42 // automatically enabling the extension if the repo requires it. |
55 if repo.has_narrow() { |
54 if repo.has_narrow() { |
56 return Err(CommandError::unsupported( |
55 return Err(CommandError::unsupported( |
57 "rhg files -r <rev> is not supported in narrow clones", |
56 "rhg files -r <rev> is not supported in narrow clones", |
58 )); |
57 )); |
59 } |
58 } |
60 let files = list_rev_tracked_files(repo, rev).map_err(|e| (e, rev))?; |
59 let files = list_rev_tracked_files(repo, rev) |
|
60 .map_err(|e| (e, rev.as_ref()))?; |
61 display_files(invocation.ui, repo, files.iter()) |
61 display_files(invocation.ui, repo, files.iter()) |
62 } else { |
62 } else { |
63 // The dirstate always reflects the sparse narrowspec, so if |
63 // The dirstate always reflects the sparse narrowspec, so if |
64 // we only have sparse without narrow all is fine. |
64 // we only have sparse without narrow all is fine. |
65 // If we have narrow, then [hg files] needs to check if |
65 // If we have narrow, then [hg files] needs to check if |