From 8c503a21cb8d6e431431c97735ddef3f67ec9613 Mon Sep 17 00:00:00 2001 From: Pierre Chevalier Date: Fri, 27 Oct 2023 06:49:59 -0700 Subject: [PATCH] newadmin: only allow bonsay hg mapping overrides when necessary Summary: This fixes a regression introduced with the port of the `derived-data` subcommand to `newadmin` (D49774292). The old implementation that was deleted in D49779178 had the same behaviour as the code does after this change: * Always override the lease for the derive subcommand * Only override the bonsai hg mapping if `rederive` is passed Reviewed By: YousefSalama Differential Revision: D50735685 fbshipit-source-id: 4193c880bbd8d988e6292ca939cbdc6636041d68 --- .../integration/test-newadmin-derive-regenerate.t | 11 ++++++++--- .../mononoke/tools/admin/src/commands/derived_data.rs | 4 +--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/eden/mononoke/tests/integration/test-newadmin-derive-regenerate.t b/eden/mononoke/tests/integration/test-newadmin-derive-regenerate.t index e8eed0cae00d2..78f2d49f630c5 100644 --- a/eden/mononoke/tests/integration/test-newadmin-derive-regenerate.t +++ b/eden/mononoke/tests/integration/test-newadmin-derive-regenerate.t @@ -67,11 +67,16 @@ $ mononoke_newadmin convert -R repo --from bonsai --to hg 1213979c6023f23e70dbe8845d773078ac1e0506bc2ab98382a329da0cb379a7 --derive 52aee0f873361473bbb29cbce0c1ba5d0c1a2c5e -# Now rederive HG_SET_COMMITTER_EXTRA=true. This changes hg hash, so let's run it with --rederive and make sure +# Now rederive HG_SET_COMMITTER_EXTRA=true. This changes hg hash, so we need to run with --rederive and make sure # hg hash was overwritten. $ HG_SET_COMMITTER_EXTRA=true ENABLED_DERIVED_DATA='["git_trees", "filenodes", "hgchangesets"]' setup_common_config - $ mononoke_newadmin derived-data -R repo derive -T hgchangesets -i 1213979c6023f23e70dbe8845d773078ac1e0506bc2ab98382a329da0cb379a7 --rederive -# Check hg hash after overwriting +# If we call derive without the rederive flag, we have the same hg hash as before + $ mononoke_newadmin derived-data -R repo derive -T hgchangesets -i 1213979c6023f23e70dbe8845d773078ac1e0506bc2ab98382a329da0cb379a7 + $ mononoke_newadmin convert -R repo --from bonsai --to hg 1213979c6023f23e70dbe8845d773078ac1e0506bc2ab98382a329da0cb379a7 + 52aee0f873361473bbb29cbce0c1ba5d0c1a2c5e + +# With rederive, we can see that the hash is now different as expected + $ mononoke_newadmin derived-data -R repo derive -T hgchangesets -i 1213979c6023f23e70dbe8845d773078ac1e0506bc2ab98382a329da0cb379a7 --rederive $ mononoke_newadmin convert -R repo --from bonsai --to hg 1213979c6023f23e70dbe8845d773078ac1e0506bc2ab98382a329da0cb379a7 c4c28fe2943cad9b4fed5a6982d3ffc0a83b4e7e diff --git a/eden/mononoke/tools/admin/src/commands/derived_data.rs b/eden/mononoke/tools/admin/src/commands/derived_data.rs index 3e112066d3daa..f20673bb273f0 100644 --- a/eden/mononoke/tools/admin/src/commands/derived_data.rs +++ b/eden/mononoke/tools/admin/src/commands/derived_data.rs @@ -101,9 +101,7 @@ pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> { .await } else { app.open_repo_with_factory_customization(&args.repo, |repo_factory| { - repo_factory - .with_lease_override(|_| Arc::new(DummyLease {})) - .with_bonsai_hg_mapping_override() + repo_factory.with_lease_override(|_| Arc::new(DummyLease {})) }) .await }