From 47502548025b35db8b238ecd8432974bbd6289e7 Mon Sep 17 00:00:00 2001 From: Garrett Beaty Date: Fri, 17 May 2024 17:49:42 +0000 Subject: [PATCH] Remove json and presentation attributes from bot_update.Result. All downstream uses have been updated, so the backward compatibility is no longer necessary. Bug: 339472834 Change-Id: Ie8434168e7d1255561e5f5434ea811f753f88835 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5534148 Reviewed-by: Yiwei Zhang Commit-Queue: Garrett Beaty --- recipes/README.recipes.md | 14 ++++----- recipes/recipe_modules/bot_update/api.py | 29 ++----------------- .../bot_update/examples/full.py | 2 +- .../ensure_checkout_return_custom_result.py | 6 ---- 4 files changed, 10 insertions(+), 41 deletions(-) diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 2a87e6e104..b25adbde52 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -57,18 +57,18 @@ Recipe module to ensure a checkout is consistent on a bot. -#### **class [BotUpdateApi](/recipes/recipe_modules/bot_update/api.py#93)([RecipeApi][recipe_engine/wkt/RecipeApi]):** +#### **class [BotUpdateApi](/recipes/recipe_modules/bot_update/api.py#71)([RecipeApi][recipe_engine/wkt/RecipeApi]):** -— **def [\_\_call\_\_](/recipes/recipe_modules/bot_update/api.py#101)(self, name, cmd, \*\*kwargs):** +— **def [\_\_call\_\_](/recipes/recipe_modules/bot_update/api.py#79)(self, name, cmd, \*\*kwargs):** Wrapper for easy calling of bot_update. -— **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#693)(self, bot_update_result):** +— **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#668)(self, bot_update_result):** Deapplies a patch, taking care of DEPS and solution revisions properly. -— **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#209)(self, gclient_config=None, suffix=None, patch=True, update_presentation=True, patch_root=None, with_branch_heads=False, with_tags=False, no_fetch_tags=False, refs=None, clobber=False, root_solution_revision=None, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, assert_one_gerrit_change=True, patch_refs=None, ignore_input_commit=False, add_blamelists=False, set_output_commit=False, step_test_data=None, enforce_fetch=False, download_topics=False, recipe_revision_overrides=None, \*\*kwargs):** +— **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#187)(self, gclient_config=None, suffix=None, patch=True, update_presentation=True, patch_root=None, with_branch_heads=False, with_tags=False, no_fetch_tags=False, refs=None, clobber=False, root_solution_revision=None, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, assert_one_gerrit_change=True, patch_refs=None, ignore_input_commit=False, add_blamelists=False, set_output_commit=False, step_test_data=None, enforce_fetch=False, download_topics=False, recipe_revision_overrides=None, \*\*kwargs):** Args: * gclient_config: The gclient configuration to use when running bot_update. @@ -104,7 +104,7 @@ Args: change's commit message to get this revision override requested by the author. -— **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#670)(self, project_name, gclient_config=None):** +— **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#645)(self, project_name, gclient_config=None):** Returns all property names used for storing the checked-out revision of a given project. @@ -118,9 +118,9 @@ Args: Returns (list of str): All properties that'll hold the checked-out revision of the given project. An empty list if no such properties exist. -  **@property**
— **def [last\_returned\_properties](/recipes/recipe_modules/bot_update/api.py#120)(self):** +  **@property**
— **def [last\_returned\_properties](/recipes/recipe_modules/bot_update/api.py#98)(self):** -— **def [resolve\_fixed\_revision](/recipes/recipe_modules/bot_update/api.py#621)(self, bot_update_json, name):** +— **def [resolve\_fixed\_revision](/recipes/recipe_modules/bot_update/api.py#596)(self, bot_update_result, name):** Sets a fixed revision for a single dependency using project revision properties. diff --git a/recipes/recipe_modules/bot_update/api.py b/recipes/recipe_modules/bot_update/api.py index 5961cebc93..a331475dab 100644 --- a/recipes/recipe_modules/bot_update/api.py +++ b/recipes/recipe_modules/bot_update/api.py @@ -31,11 +31,6 @@ class RelativeRoot: return cls(name=name, path=checkout_dir / name) -@dataclasses.dataclass(kw_only=True, frozen=True) -class Json: - output: dict[str, typing.Any] - - class ManifestRepo(typing.TypedDict): repository: str revision: str @@ -72,23 +67,6 @@ class Result: manifest: dict[str, ManifestRepo] fixed_revisions: dict[str, str] - # TODO: crbug.com/339472834 - Once all downstream users are switched to use - # the above fields, these attributes and the property methods can be removed, - # as well as the Json type - _api: 'BotUpdateApi' - _presentation: StepPresentation - _json: Json - - @property - def presentation(self): - self._api.m.warning.issue('BOT_UPDATE_CUSTOM_RESULT_ATTRIBUTES') - return self._presentation - - @property - def json(self): - self._api.m.warning.issue('BOT_UPDATE_CUSTOM_RESULT_ATTRIBUTES') - return self._json - class BotUpdateApi(recipe_api.RecipeApi): @@ -586,9 +564,6 @@ class BotUpdateApi(recipe_api.RecipeApi): properties=result.get('properties', {}), manifest=result.get('manifest', {}), fixed_revisions=result.get('fixed_revisions', {}), - _api=self, - _presentation=step_result.presentation, - _json=Json(output=result), ) def _destination_ref(self, cfg, path): @@ -618,13 +593,13 @@ class BotUpdateApi(recipe_api.RecipeApi): return self.m.tryserver.gerrit_change_target_ref - def resolve_fixed_revision(self, bot_update_json, name): + def resolve_fixed_revision(self, bot_update_result, name): """Sets a fixed revision for a single dependency using project revision properties. """ rev_properties = self.get_project_revision_properties(name) self.m.gclient.c.revisions = { - name: bot_update_json['properties'][rev_properties[0]] + name: bot_update_result.properties[rev_properties[0]] } def _resolve_fixed_revisions(self, bot_update_result): diff --git a/recipes/recipe_modules/bot_update/examples/full.py b/recipes/recipe_modules/bot_update/examples/full.py index 566ba8317a..29f84017d6 100644 --- a/recipes/recipe_modules/bot_update/examples/full.py +++ b/recipes/recipe_modules/bot_update/examples/full.py @@ -93,7 +93,7 @@ def RunSteps(api): api.bot_update.deapply_patch(bot_update_step) if api.properties.get('resolve_chromium_fixed_version'): - api.bot_update.resolve_fixed_revision(bot_update_step.json.output, 'src') + api.bot_update.resolve_fixed_revision(bot_update_step, 'src') def GenTests(api): diff --git a/recipes/recipe_modules/bot_update/tests/ensure_checkout_return_custom_result.py b/recipes/recipe_modules/bot_update/tests/ensure_checkout_return_custom_result.py index c2b2fe5863..5af2c1ef21 100644 --- a/recipes/recipe_modules/bot_update/tests/ensure_checkout_return_custom_result.py +++ b/recipes/recipe_modules/bot_update/tests/ensure_checkout_return_custom_result.py @@ -45,12 +45,6 @@ def RunSteps(api, expected_checkout_dir, expected_source_root_name, else: api.assertions.assertIsNone(result.patch_root) - api.assertions.assertEqual(result.properties, result.presentation.properties) - api.assertions.assertEqual(result.manifest, - result.json.output.get('manifest', {})) - api.assertions.assertEqual(result.fixed_revisions, - result.json.output.get('fixed_revisions', {})) - def GenTests(api): yield api.test(