@ -67,7 +67,8 @@ def AddUploadedByGitClSplitToDescription(description):
def UploadCl ( refactor_branch , refactor_branch_upstream , directory , files ,
description , comment , reviewers , changelist , cmd_upload ) :
description , comment , reviewers , changelist , cmd_upload ,
cq_dry_run ) :
""" Uploads a CL with all changes to |files| in |refactor_branch|.
Args :
@ -81,6 +82,7 @@ def UploadCl(refactor_branch, refactor_branch_upstream, directory, files,
reviewers : A set of reviewers for the CL .
changelist : The Changelist class .
cmd_upload : The function associated with the git cl upload command .
cq_dry_run : If CL uploads should also do a cq dry run .
"""
# Create a branch.
if not CreateBranchForDirectory (
@ -107,7 +109,9 @@ def UploadCl(refactor_branch, refactor_branch_upstream, directory, files,
os . remove ( tmp_file . name )
# Upload a CL.
upload_args = [ ' -f ' , ' --cq-dry-run ' , ' -r ' , ' , ' . join ( reviewers ) ]
upload_args = [ ' -f ' , ' -r ' , ' , ' . join ( reviewers ) ]
if cq_dry_run :
upload_args . append ( ' --cq-dry-run ' )
if not comment :
upload_args . append ( ' --send-mail ' )
print ' Uploading CL for ' + directory + ' . '
@ -156,7 +160,8 @@ def PrintClInfo(cl_index, num_cls, directory, file_paths, description,
print
def SplitCl ( description_file , comment_file , changelist , cmd_upload , dry_run ) :
def SplitCl ( description_file , comment_file , changelist , cmd_upload , dry_run ,
cq_dry_run ) :
""" " Splits a branch into smaller branches and uploads CLs.
Args :
@ -165,6 +170,7 @@ def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run):
changelist : The Changelist class .
cmd_upload : The function associated with the git cl upload command .
dry_run : Whether this is a dry run ( no branches or CLs created ) .
cq_dry_run : If CL uploads should also do a cq dry run .
Returns :
0 in case of success . 1 in case of error .
@ -198,6 +204,16 @@ def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run):
num_cls = len ( files_split_by_owners )
print ( ' Will split current branch ( ' + refactor_branch + ' ) into ' +
str ( num_cls ) + ' CLs. \n ' )
if cq_dry_ru 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
answer = raw_input ( ' Proceed? (y/n): ' )
if answer . lower ( ) != ' y ' :
return 0
for cl_index , ( directory , files ) in \
enumerate ( files_split_by_owners . iteritems ( ) , 1 ) :
@ -212,7 +228,8 @@ def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run):
reviewers )
else :
UploadCl ( refactor_branch , refactor_branch_upstream , directory , files ,
description , comment , reviewers , changelist , cmd_upload )
description , comment , reviewers , changelist , cmd_upload ,
cq_dry_run )
# Go back to the original branch.
git . run ( ' checkout ' , refactor_branch )