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
experimental/szager/collated-output
chrisha@chromium.org 12 years ago
parent 9d66f480c8
commit 40e5d3dfa1

@ -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

Loading…
Cancel
Save