From 85cf1d8202534a7352a32ee4ca8ad57911524274 Mon Sep 17 00:00:00 2001 From: Pierre Chevalier Date: Tue, 29 Nov 2022 05:19:11 -0800 Subject: [PATCH] Fix --dry-run flag Summary: Currently, `mononoke_newadmin` can be used with a command like ``` monoke_newadmin -- --prod hg-sync --repo-id 2103 last-processed --dry-run --set 42 ``` It won't dry run, but it will actually set the last processed ID in prod. That is scary. It is due to a surprising behaviour of clap that I reported upstream here: https://github.com/clap-rs/clap/issues/4520. Work around what is likely an upstream bug by adding an explicit `conflicts_with` configuration. Reviewed By: YousefSalama, yancouto Differential Revision: D41555183 fbshipit-source-id: 482046ade24b60961c3f3c19c309695ba4116b40 --- .../tools/admin/src/commands/hg_sync/last_processed.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/eden/mononoke/tools/admin/src/commands/hg_sync/last_processed.rs b/eden/mononoke/tools/admin/src/commands/hg_sync/last_processed.rs index df6a6822e7215..6f8562a57dd7e 100644 --- a/eden/mononoke/tools/admin/src/commands/hg_sync/last_processed.rs +++ b/eden/mononoke/tools/admin/src/commands/hg_sync/last_processed.rs @@ -32,7 +32,14 @@ pub struct HgSyncLastProcessedArgs { /// When skipping over blobimport entries, don't update the last processed /// entry, just print what would happen - #[clap(long, short = 'n', requires = "skip-blobimport")] + #[clap( + long, + short = 'n', + requires = "skip-blobimport", + conflicts_with = "set" + )] // You would think this "conflicts_with" wouldn't be required, but it is, due + // to a weird interaction with the `conflicts_with` on `skip_blobimport`. + // See upstream issue: https://github.com/clap-rs/clap/issues/4520 dry_run: bool, }