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 <linxinan@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Michael Moss <mmoss@chromium.org>
This commit is contained in:
Xinan Lin
2021-10-20 19:51:57 +00:00
committed by LUCI CQ
parent b6ce244503
commit 57f8581806
2 changed files with 11 additions and 3 deletions

View File

@@ -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',