Improve git cl split warning if more than 10 CLs will be created.

This CL updates the warning printed when more than 10 CLs will be
created to be shown whether or not the CLs are being sent to the CQ
and provides guidance on adjusting the number of CLs using the max-depth
flag. This makes the tool more user friendly by preventing a new user
from unknowingly creating many CLs without realizing there is a
supported option to customize the depth.

Additionally, it sets the default for the cq-dry-run option to False
instead of None and logs the value of cq_dry_run when running a git cl
split dry run.

Change-Id: I6feba24d06dd5e88d9005345d5b0a1e15c53e197
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5234543
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
changes/43/5234543/3
Mike Dougherty 1 year ago committed by LUCI CQ
parent b25b4680f2
commit 68c511349d

@ -5405,6 +5405,7 @@ def CMDsplit(parser, args):
'be created, but don\'t create branches or CLs.')
parser.add_option('--cq-dry-run',
action='store_true',
default=False,
help='If set, will do a cq dry run for each uploaded CL. '
'Please be careful when doing this; more than ~10 CLs '
'has the potential to overload our build '

@ -188,7 +188,7 @@ def GetFilesSplitByOwners(files, max_depth):
def PrintClInfo(cl_index, num_cls, directories, file_paths, description,
reviewers, enable_auto_submit, topic):
reviewers, cq_dry_run, enable_auto_submit, topic):
"""Prints info about a CL.
Args:
@ -199,6 +199,7 @@ def PrintClInfo(cl_index, num_cls, directories, file_paths, description,
file_paths: A list of files in this CL.
description: The CL description.
reviewers: A set of reviewers for this CL.
cq_dry_run: If the CL should also be sent to CQ dry run.
enable_auto_submit: If the CL should also have auto submit enabled.
topic: Topic to set for this CL.
"""
@ -210,6 +211,7 @@ def PrintClInfo(cl_index, num_cls, directories, file_paths, description,
print('Paths: {}'.format(FormatDirectoriesForPrinting(directories)))
print('Reviewers: {}'.format(', '.join(reviewers)))
print('Auto-Submit: {}'.format(enable_auto_submit))
print('CQ Dry Run: {}'.format(cq_dry_run))
print('Topic: {}'.format(topic))
print('\n' + indented_description + '\n')
print('\n'.join(file_paths))
@ -269,13 +271,17 @@ def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run,
num_cls = len(files_split_by_reviewers)
print('Will split current branch (' + refactor_branch + ') into ' +
str(num_cls) + ' CLs.\n')
if cq_dry_run and num_cls > CL_SPLIT_FORCE_LIMIT:
if not dry_run and num_cls > CL_SPLIT_FORCE_LIMIT:
print(
'This will generate "%r" CLs. This many CLs can potentially'
' generate too much load on the build infrastructure. Please'
' email infra-dev@chromium.org to ensure that this won\'t break'
' anything. The infra team reserves the right to cancel your'
' jobs if they are overloading the CQ.' % num_cls)
' generate too much load on the build infrastructure.\n\n'
'Please email infra-dev@chromium.org to ensure that this won\'t'
'break anything. The infra team reserves the right to cancel'
'your jobs if they are overloading the CQ.\n\n'
'(Alternatively, you can reduce the number of CLs created by'
' using the --max-depth option. Pass --dry-run to examine the'
' CLs which will be created until you are happy with the'
' results.)' % num_cls)
answer = gclient_utils.AskForData('Proceed? (y/n):')
if answer.lower() != 'y':
return 0
@ -288,7 +294,7 @@ def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run,
if dry_run:
file_paths = [f for _, f in cl_info.files]
PrintClInfo(cl_index, num_cls, cl_info.owners_directories,
file_paths, description, reviewer_set,
file_paths, description, reviewer_set, cq_dry_run,
enable_auto_submit, topic)
else:
UploadCl(refactor_branch, refactor_branch_upstream,

Loading…
Cancel
Save