comparison rust/rhg/src/main.rs @ 48075:f11f233546ce

rhg: fallback if the current command has any generic hook defined We do not handle hooks yet. Differential Revision: https://phab.mercurial-scm.org/D11380
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 01 Sep 2021 17:41:51 +0200
parents cff41e168c25
children b44e1184b7e1
comparison
equal deleted inserted replaced
48074:4a6fa6b6f079 48075:f11f233546ce
66 let app = add_subcommand_args(app); 66 let app = add_subcommand_args(app);
67 67
68 let matches = app.clone().get_matches_safe()?; 68 let matches = app.clone().get_matches_safe()?;
69 69
70 let (subcommand_name, subcommand_matches) = matches.subcommand(); 70 let (subcommand_name, subcommand_matches) = matches.subcommand();
71
72 for prefix in ["pre", "post", "fail"].iter() {
73 // Mercurial allows users to define generic hooks for commands,
74 // fallback if any are detected
75 let item = format!("{}-{}", prefix, subcommand_name);
76 let hook_for_command = config.get_str(b"hooks", item.as_bytes())?;
77 if hook_for_command.is_some() {
78 let msg = format!("{}-{} hook defined", prefix, subcommand_name);
79 return Err(CommandError::unsupported(msg));
80 }
81 }
71 let run = subcommand_run_fn(subcommand_name) 82 let run = subcommand_run_fn(subcommand_name)
72 .expect("unknown subcommand name from clap despite AppSettings::SubcommandRequired"); 83 .expect("unknown subcommand name from clap despite AppSettings::SubcommandRequired");
73 let subcommand_args = subcommand_matches 84 let subcommand_args = subcommand_matches
74 .expect("no subcommand arguments from clap despite AppSettings::SubcommandRequired"); 85 .expect("no subcommand arguments from clap despite AppSettings::SubcommandRequired");
75 86