comparison rust/rhg/src/commands/files.rs @ 49758:37bc3edef76f

rhg: upgrade `clap` dependency This one is the worst one to upgrade since v2 -> v4 broke a ton of API, which thankfully seems saner now. Contrary to what was done in the `hg-core/src/examples/nodemap` rewrite, we're not switching from the "builder" pattern to the "derive" pattern, since that would imply a much larger diff. It can be done incrementally.
author Rapha?l Gom?s <rgomes@octobus.net>
date Tue, 15 Nov 2022 00:02:43 +0100
parents 9b0e1f64656f
children e43f91244de2
comparison
equal deleted inserted replaced
49757:5844cd8e81ca 49758:37bc3edef76f
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