Commit 51ee0071 authored by maruel@chromium.org's avatar maruel@chromium.org

Add --force as a synonym for --no_presubmit as per Nicolas' request.

Factor out some code in FilterFlag() to make the code much more readable.

TEST=none
BUG=none

Review URL: http://codereview.chromium.org/119315

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@17884 0039d316-1c4b-4281-b951-d872f2087c98
parent 44a17adf
......@@ -245,6 +245,17 @@ def WriteFile(filename, contents):
file.close()
def FilterFlag(args, flag):
"""Returns True if the flag is present in args list.
The flag is removed from args if present.
"""
if flag in args:
args.remove(flag)
return True
return False
class ChangeInfo(object):
"""Holds information about a changelist.
......@@ -713,36 +724,27 @@ def GenerateDiff(files, root=None):
return "".join(diff)
def OptionallyDoPresubmitChecks(change_info, committing, args):
if FilterFlag(args, "--no_presubmit") or FilterFlag(args, "--force"):
return True
return DoPresubmitChecks(change_info, committing=committing)
def UploadCL(change_info, args):
if not change_info.FileList():
print "Nothing to upload, changelist is empty."
return
if not "--no_presubmit" in args:
if not DoPresubmitChecks(change_info, committing=False):
return
else:
args.remove("--no_presubmit")
no_try = "--no_try" in args
if no_try:
args.remove("--no_try")
else:
# Support --no-try as --no_try
no_try = "--no-try" in args
if no_try:
args.remove("--no-try")
if not OptionallyDoPresubmitChecks(change_info, False, args):
return
no_try = FilterFlag(args, "--no_try") or FilterFlag(args, "--no-try")
# Map --send-mail to --send_mail
if "--send-mail" in args:
args.remove("--send-mail")
if FilterFlag(args, "--send-mail"):
args.append("--send_mail")
# Supports --clobber for the try server.
clobber = False
if "--clobber" in args:
args.remove("--clobber")
clobber = True
clobber = FilterFlag(args, "--clobber")
# Disable try when the server is overridden.
server_1 = re.compile(r"^-s\b.*")
......@@ -866,12 +868,8 @@ def Commit(change_info, args):
if not change_info.FileList():
print "Nothing to commit, changelist is empty."
return
if not "--no_presubmit" in args:
if not DoPresubmitChecks(change_info, committing=True):
return
else:
args.remove("--no_presubmit")
if not OptionallyDoPresubmitChecks(change_info, True, args):
return
# We face a problem with svn here: Let's say change 'bleh' modifies
# svn:ignore on dir1\. but another unrelated change 'pouet' modifies
......
......@@ -42,15 +42,16 @@ class GclUnittest(GclTestsBase):
members = [
'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 'CPP_EXTENSIONS',
'Change', 'ChangeInfo', 'Changes', 'Commit', 'DoPresubmitChecks',
'ErrorExit', 'FILES_CACHE', 'GenerateChangeName', 'GenerateDiff',
'ErrorExit', 'FILES_CACHE', 'FilterFlag', 'GenerateChangeName',
'GenerateDiff',
'GetCacheDir', 'GetCachedFile', 'GetChangesDir', 'GetCLs',
'GetChangelistInfoFile', 'GetCodeReviewSetting', 'GetEditor',
'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription',
'GetModifiedFiles', 'GetRepositoryRoot',
'GetSVNFileProperty', 'Help', 'IGNORE_PATHS', 'IsSVNMoved',
'Lint', 'LoadChangelistInfoForMultiple',
'MISSING_TEST_MSG', 'Opened', 'PresubmitCL', 'ReadFile',
'REPOSITORY_ROOT', 'RunShell',
'MISSING_TEST_MSG', 'Opened', 'OptionallyDoPresubmitChecks',
'PresubmitCL', 'ReadFile', 'REPOSITORY_ROOT', 'RunShell',
'RunShellWithReturnCode', 'SendToRietveld', 'TryChange',
'UnknownFiles', 'UploadCL', 'Warn', 'WriteFile',
'gclient', 'getpass', 'main', 'os', 'random', 're',
......
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