From 53e28ecb9f9505c38c01a6ed80730fc28469402f Mon Sep 17 00:00:00 2001 From: Nodir Turakulov Date: Tue, 18 Sep 2018 23:00:49 +0000 Subject: [PATCH] [gclient] Remove calculate_patch_root It is not used. get_gerrit_patch_root is used instead. Bug: 694348 Change-Id: Icc717e38cbcaa8050c8ce8a364202b81d7f9cf2c Reviewed-on: https://chromium-review.googlesource.com/1231282 Auto-Submit: Nodir Turakulov Reviewed-by: Edward Lesmes Commit-Queue: Nodir Turakulov --- recipes/README.recipes.md | 25 +------------ recipes/recipe_modules/gclient/api.py | 37 ------------------- .../gclient/tests/patch_project.py | 3 -- recipes/recipe_modules/tryserver/api.py | 2 +- .../recipe_modules/tryserver/examples/full.py | 2 +- 5 files changed, 4 insertions(+), 65 deletions(-) diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index aed6bc5021..f8d1ae0218 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -247,27 +247,6 @@ Wrapper for easy calling of gclient steps. Remove all index.lock files. If a previous run of git crashed, bot was reset, etc... we might end up with leftover index.lock files. -— **def [calculate\_patch\_root](/recipes/recipe_modules/gclient/api.py#362)(self, patch_project, gclient_config=None, patch_repo=None):** - -Returns path where a patch should be applied to based patch_project. - -TODO(nodir): delete this function in favor of get_repo_path. - -Maps the patch's repo to a path of directories relative to checkout's root, -which describe where to place the patch. If no mapping is found for the -repo url, falls back to trying to find a mapping for the old-style -"patch_project". - -For now, considers only first solution (c.solutions[0]), but in theory can -be extended to all of them. - -See patch_projects and repo_path_map solution config property. - -Returns: - Relative path, including solution's root. - If patch_project is not given or not recognized, it'll be just first - solution root. - — **def [checkout](/recipes/recipe_modules/gclient/api.py#230)(self, gclient_config=None, revert=RevertOnTryserver, inject_parent_got_revision=True, extra_sync_flags=None, \*\*kwargs):** Return a step generator function for gclient checkouts. @@ -328,7 +307,7 @@ Chromium config. This may happen for one of two reasons: — **def [runhooks](/recipes/recipe_modules/gclient/api.py#264)(self, args=None, name='runhooks', \*\*kwargs):** -— **def [set\_patch\_repo\_revision](/recipes/recipe_modules/gclient/api.py#399)(self, gclient_config=None):** +— **def [set\_patch\_repo\_revision](/recipes/recipe_modules/gclient/api.py#362)(self, gclient_config=None):** Updates config revision corresponding to patch_project. @@ -813,7 +792,7 @@ Returns list of paths to files affected by the patch. Argument: patch_root: path relative to api.path['root'], usually obtained from - api.gclient.calculate_patch_root(patch_project) + api.gclient.get_gerrit_patch_root(). Returned paths will be relative to to patch_root. diff --git a/recipes/recipe_modules/gclient/api.py b/recipes/recipe_modules/gclient/api.py index 45b06a1dad..779e520422 100644 --- a/recipes/recipe_modules/gclient/api.py +++ b/recipes/recipe_modules/gclient/api.py @@ -359,43 +359,6 @@ class GclientApi(recipe_api.RecipeApi): return None - def calculate_patch_root(self, patch_project, gclient_config=None, - patch_repo=None): # pragma: no cover - """Returns path where a patch should be applied to based patch_project. - - TODO(nodir): delete this function in favor of get_repo_path. - - Maps the patch's repo to a path of directories relative to checkout's root, - which describe where to place the patch. If no mapping is found for the - repo url, falls back to trying to find a mapping for the old-style - "patch_project". - - For now, considers only first solution (c.solutions[0]), but in theory can - be extended to all of them. - - See patch_projects and repo_path_map solution config property. - - Returns: - Relative path, including solution's root. - If patch_project is not given or not recognized, it'll be just first - solution root. - """ - if patch_repo: - path = self.get_repo_path(patch_repo, gclient_config=gclient_config) - if path is not None: - return path - - cfg = gclient_config or self.c - root, _ = cfg.patch_projects.get(patch_project, ('', '')) - if not root: - # Failure case - assume patch is for first solution, as this is what most - # projects rely on. - return cfg.solutions[0].name - # Note, that c.patch_projects contains patch roots as - # slash(/)-separated path, which are roots of the respective project repos - # and include actual solution name in them. - return self.m.path.join(*root.split('/')) - def set_patch_repo_revision(self, gclient_config=None): """Updates config revision corresponding to patch_project. diff --git a/recipes/recipe_modules/gclient/tests/patch_project.py b/recipes/recipe_modules/gclient/tests/patch_project.py index af400213ef..2d033f6682 100644 --- a/recipes/recipe_modules/gclient/tests/patch_project.py +++ b/recipes/recipe_modules/gclient/tests/patch_project.py @@ -53,9 +53,6 @@ def RunSteps(api, patch_project, patch_repository_url): patch_root = api.gclient.get_gerrit_patch_root(gclient_config=src_cfg) assert patch_root == api.properties['expected_patch_root'], patch_root - api.gclient.calculate_patch_root( - patch_project, None, patch_repository_url) - api.gclient.set_patch_repo_revision() diff --git a/recipes/recipe_modules/tryserver/api.py b/recipes/recipe_modules/tryserver/api.py index 9592478a28..c95ca55616 100644 --- a/recipes/recipe_modules/tryserver/api.py +++ b/recipes/recipe_modules/tryserver/api.py @@ -138,7 +138,7 @@ class TryserverApi(recipe_api.RecipeApi): Argument: patch_root: path relative to api.path['root'], usually obtained from - api.gclient.calculate_patch_root(patch_project) + api.gclient.get_gerrit_patch_root(). Returned paths will be relative to to patch_root. """ diff --git a/recipes/recipe_modules/tryserver/examples/full.py b/recipes/recipe_modules/tryserver/examples/full.py index 586578af7b..313320eeea 100644 --- a/recipes/recipe_modules/tryserver/examples/full.py +++ b/recipes/recipe_modules/tryserver/examples/full.py @@ -61,7 +61,7 @@ def GenTests(api): 'git_cl description', stdout=api.raw_io.output_text('foobar')) # The 'test_patch_root' property used below is just so that these # tests can avoid using the gclient module to calculate the - # patch root. Normal users would use gclient.calculate_patch_root(). + # patch root. Normal users would use gclient.get_gerrit_patch_root(). yield (api.test('with_git_patch') + api.properties( path_config='buildbot',