Commit 57f85818 authored by Xinan Lin's avatar Xinan Lin Committed by LUCI CQ

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: 's avatarDirk Pranke <dpranke@google.com>
Reviewed-by: 's avatarMichael Moss <mmoss@chromium.org>
parent b6ce2445
......@@ -343,7 +343,7 @@ Returns:
&mdash; **def [set\_change\_label](/recipes/recipe_modules/gerrit/api.py#248)(self, host, change, label_name, label_value, name=None, step_test_data=None):**
&mdash; **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):**
&mdash; **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:
......
......@@ -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',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment