1# Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) 2# 3# Redistribution and use in source and binary forms, with or without 4# modification, are permitted provided that the following conditions 5# are met: 6# 1. Redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer. 8# 2. Redistributions in binary form must reproduce the above copyright 9# notice, this list of conditions and the following disclaimer in the 10# documentation and/or other materials provided with the distribution. 11# 12# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY 13# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY 16# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 18# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 19# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 23"""References to non-style modules used by the style package.""" 24 25# This module is a simple facade to the functionality used by the 26# style package that comes from WebKit modules outside the style 27# package. 28# 29# With this module, the only intra-package references (i.e. 30# references to webkitpy modules outside the style folder) that 31# the style package needs to make are relative references to 32# this module. For example-- 33# 34# > from .. style_references import parse_patch 35# 36# Similarly, people maintaining non-style code are not beholden 37# to the contents of the style package when refactoring or 38# otherwise changing non-style code. They only have to be aware 39# of this module. 40 41import os 42 43from webkitpy.common.checkout.diff_parser import DiffParser 44from webkitpy.common.system.logtesting import LogTesting 45from webkitpy.common.system.logtesting import TestLogStream 46from webkitpy.common.system.logutils import configure_logging 47from webkitpy.common.checkout.scm import detect_scm_system 48from webkitpy.layout_tests import port 49from webkitpy.layout_tests.layout_package import test_expectations 50from webkitpy.thirdparty.autoinstalled import pep8 51 52 53def detect_checkout(): 54 """Return a WebKitCheckout instance, or None if it cannot be found.""" 55 cwd = os.path.abspath(os.curdir) 56 scm = detect_scm_system(cwd) 57 58 return None if scm is None else WebKitCheckout(scm) 59 60 61class WebKitCheckout(object): 62 63 """Simple facade to the SCM class for use by style package.""" 64 65 def __init__(self, scm): 66 self._scm = scm 67 68 def root_path(self): 69 """Return the checkout root as an absolute path.""" 70 return self._scm.checkout_root 71 72 def create_patch(self, git_commit, changed_files=None): 73 return self._scm.create_patch(git_commit, changed_files=changed_files) 74