Commit e72bb63e authored by dpranke@google.com's avatar dpranke@google.com

Revise change in r30415 to properly climb local directories looking for a

modified codereview.settings or presubmit file.

  BUG=none
  R=maruel@chromium.org
  TEST=none

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@30503 0039d316-1c4b-4281-b951-d872f2087c98
parent bb816387
......@@ -145,6 +145,8 @@ def GetCachedFile(filename, max_age=60*60*24*3, use_root=False):
return None
if (not os.path.exists(cached_file) or
os.stat(cached_file).st_mtime > max_age):
local_dir = os.path.dirname(os.path.abspath(filename))
local_base = os.path.basename(filename)
dir_info = gclient_scm.CaptureSVNInfo(".")
repo_root = dir_info["Repository Root"]
if use_root:
......@@ -153,13 +155,14 @@ def GetCachedFile(filename, max_age=60*60*24*3, use_root=False):
url_path = dir_info["URL"]
content = ""
while True:
# First, look for a locally modified version of codereview.settings.
content, rc = RunShellWithReturnCode(["svn", "status", filename])
# First, look for a locally modified version of the file.
local_path = os.path.join(local_dir, local_base)
content, rc = RunShellWithReturnCode(["svn", "status", local_path])
if not rc and content.startswith('M'):
content = ReadFile(filename)
content = ReadFile(local_path)
rc = 0
else:
# Then look in the repository
# Then look in the repository.
svn_path = url_path + "/" + filename
content, rc = RunShellWithReturnCode(["svn", "cat", svn_path])
......@@ -173,6 +176,7 @@ def GetCachedFile(filename, max_age=60*60*24*3, use_root=False):
break
# Go up one level to try again.
url_path = os.path.dirname(url_path)
local_dir = os.path.dirname(local_dir)
# Write a cached version even if there isn't a file, so we don't try to
# fetch it each time.
WriteFile(cached_file, content)
......@@ -1080,12 +1084,9 @@ def Change(change_info, args):
if change_info.MissingTests():
Warn("WARNING: " + MISSING_TEST_MSG)
# We don't lint files in these path prefixes.
IGNORE_PATHS = (os.path.join("webkit","api"),)
# Valid extensions for files we want to lint.
LINT_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)"
LINT_IGNORE_REGEX = r""
DEFAULT_LINT_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)"
DEFAULT_LINT_IGNORE_REGEX = r""
def Lint(change_info, args):
"""Runs cpplint.py on all the files in |change_info|"""
......@@ -1104,11 +1105,11 @@ def Lint(change_info, args):
white_list = GetCodeReviewSetting("LINT_REGEX")
if not white_list:
white_list = LINT_REGEX
white_list = DEFAULT_LINT_REGEX
white_regex = re.compile(white_list)
black_list = GetCodeReviewSetting("LINT_IGNORE_REGEX")
if not black_list:
black_list = LINT_IGNORE_REGEX
black_list = DEFAULT_LINT_IGNORE_REGEX
black_regex = re.compile(black_list)
for file in filenames:
if white_regex.match(file):
......
......@@ -41,16 +41,16 @@ class GclUnittest(GclTestsBase):
self.mox.ReplayAll()
members = [
'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE',
'Change', 'ChangeInfo', 'Changes', 'DeleteEmptyChangeLists', 'Commit',
'DoPresubmitChecks',
'Change', 'ChangeInfo', 'Changes', 'Commit',
'DEFAULT_LINT_IGNORE_REGEX', 'DEFAULT_LINT_REGEX',
'DeleteEmptyChangeLists', 'DoPresubmitChecks',
'ErrorExit', 'FILES_CACHE', 'FilterFlag', 'GenerateChangeName',
'GenerateDiff',
'GetCacheDir', 'GetCachedFile', 'GetChangesDir', 'GetCLs',
'GetChangelistInfoFile', 'GetCodeReviewSetting', 'GetEditor',
'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription',
'GetModifiedFiles', 'GetRepositoryRoot',
'GetSVNFileProperty', 'Help', 'IGNORE_PATHS', 'IsSVNMoved',
'LINT_IGNORE_REGEX', 'LINT_REGEX',
'GetSVNFileProperty', 'Help', 'IsSVNMoved',
'Lint', 'LoadChangelistInfoForMultiple',
'MISSING_TEST_MSG', 'Opened', 'OptionallyDoPresubmitChecks',
'PresubmitCL', 'ReadFile', 'REPOSITORY_ROOT', 'RunShell',
......
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