From 40e5d3dfa11f5515d18c9efc9c86156489a69125 Mon Sep 17 00:00:00 2001 From: "chrisha@chromium.org" Date: Fri, 18 Jan 2013 17:46:57 +0000 Subject: [PATCH] Fix pylint presubmit check so that it works on Windows. r176777 introduced a change that relied on os.path.samepath, which does not exist on Windows. BUG= Review URL: https://chromiumcodereview.appspot.com/12021013 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@177701 0039d316-1c4b-4281-b951-d872f2087c98 --- presubmit_canned_checks.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 90c79ccfc..5516ca3aa 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -643,9 +643,15 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None, # Only trigger if there is at least one python file affected. def rel_path(regex): """Modifies a regex for a subject to accept paths relative to root.""" - if input_api.os_path.samefile( - input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot()): + def samefile(a, b): + # Default implementation for platforms lacking os.path.samefile + # (like Windows). + return input_api.os_path.abspath(a) == input_api.os_path.abspath(b) + samefile = getattr(input_api.os_path, 'samefile', samefile) + if samefile(input_api.PresubmitLocalPath(), + input_api.change.RepositoryRoot()): return regex + prefix = input_api.os_path.join(input_api.os_path.relpath( input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot()), '') return input_api.re.escape(prefix) + regex