From 57f85818060fdf66aea9aa3586ee130dfdea4dbb Mon Sep 17 00:00:00 2001 From: Xinan Lin Date: Wed, 20 Oct 2021 19:51:57 +0000 Subject: [PATCH] Add option to always "set bot-commit+1" in update_files() method If one uses update_files() method to file a chain of CLs and wants to submit them together, they have to set submit=False to wait for the last CL. As a result, users have to run `set Bot-Commit+1` for each CL at their side, which is annoying. This change makes the gerrit module to handle that, and callers only need to submit the chain. BUG=1261724 TEST=train Change-Id: If7d420d8d3c40b1d462284395cdc87ac680d0918 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3235388 Commit-Queue: Xinan Lin Reviewed-by: Dirk Pranke Reviewed-by: Michael Moss --- recipes/README.recipes.md | 5 ++++- recipes/recipe_modules/gerrit/api.py | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 14e691fb7f..fcfb004d06 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -343,7 +343,7 @@ Returns: — **def [set\_change\_label](/recipes/recipe_modules/gerrit/api.py#248)(self, host, change, label_name, label_value, name=None, step_test_data=None):** -— **def [update\_files](/recipes/recipe_modules/gerrit/api.py#290)(self, host, project, branch, new_contents_by_file_path, commit_msg, params=frozenset(['status=NEW']), submit=False):** +— **def [update\_files](/recipes/recipe_modules/gerrit/api.py#290)(self, host, project, branch, new_contents_by_file_path, commit_msg, params=frozenset(['status=NEW']), submit=False, submit_later=False):** Update a set of files by creating and submitting a Gerrit CL. @@ -357,6 +357,9 @@ Args: * params: A list of additional ChangeInput specifiers, with format 'key=value'. * submit: Should land this CL instantly. + * submit_later: If this change has related CLs, we may want to commit + them in a chain. So only set Bot-Commit+1, making it ready for + submit together. Ignored if submit is True. Returns: A ChangeInfo dictionary as documented here: diff --git a/recipes/recipe_modules/gerrit/api.py b/recipes/recipe_modules/gerrit/api.py index be4dac2aa2..38de53439d 100644 --- a/recipes/recipe_modules/gerrit/api.py +++ b/recipes/recipe_modules/gerrit/api.py @@ -294,7 +294,8 @@ class GerritApi(recipe_api.RecipeApi): new_contents_by_file_path, commit_msg, params=frozenset(['status=NEW']), - submit=False): + submit=False, + submit_later=False): """Update a set of files by creating and submitting a Gerrit CL. Args: @@ -307,6 +308,9 @@ class GerritApi(recipe_api.RecipeApi): * params: A list of additional ChangeInput specifiers, with format 'key=value'. * submit: Should land this CL instantly. + * submit_later: If this change has related CLs, we may want to commit + them in a chain. So only set Bot-Commit+1, making it ready for + submit together. Ignored if submit is True. Returns: A ChangeInfo dictionary as documented here: @@ -361,7 +365,7 @@ class GerritApi(recipe_api.RecipeApi): change, ]) - if submit: + if submit or submit_later: self('set Bot-Commit+1 for change %d' % change, [ 'setbotcommit', '--host', @@ -369,6 +373,7 @@ class GerritApi(recipe_api.RecipeApi): '--change', change, ]) + if submit: submit_cmd = [ 'submitchange', '--host',