From e72bb63e3e34c957a654e16093cd544f288d5f65 Mon Sep 17 00:00:00 2001 From: "dpranke@google.com" Date: Thu, 29 Oct 2009 20:15:48 +0000 Subject: [PATCH] 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 --- gcl.py | 23 ++++++++++++----------- tests/gcl_unittest.py | 8 ++++---- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/gcl.py b/gcl.py index 2a81861d5..db5371c4a 100755 --- a/gcl.py +++ b/gcl.py @@ -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): diff --git a/tests/gcl_unittest.py b/tests/gcl_unittest.py index 8e3035784..59efd8442 100755 --- a/tests/gcl_unittest.py +++ b/tests/gcl_unittest.py @@ -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',