WebKitTools/Scripts/webkitpy/style_references.py
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     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 
       
    41 import os
       
    42 
       
    43 from webkitpy.common.checkout.diff_parser import DiffParser
       
    44 from webkitpy.common.system.logtesting import LogTesting
       
    45 from webkitpy.common.system.logtesting import TestLogStream
       
    46 from webkitpy.common.system.logutils import configure_logging
       
    47 from webkitpy.common.checkout.scm import detect_scm_system
       
    48 from webkitpy.thirdparty.autoinstalled import pep8
       
    49 
       
    50 
       
    51 def detect_checkout():
       
    52     """Return a WebKitCheckout instance, or None if it cannot be found."""
       
    53     cwd = os.path.abspath(os.curdir)
       
    54     scm = detect_scm_system(cwd)
       
    55 
       
    56     return None if scm is None else WebKitCheckout(scm)
       
    57 
       
    58 
       
    59 class WebKitCheckout(object):
       
    60 
       
    61     """Simple facade to the SCM class for use by style package."""
       
    62 
       
    63     def __init__(self, scm):
       
    64         self._scm = scm
       
    65 
       
    66     def root_path(self):
       
    67         """Return the checkout root as an absolute path."""
       
    68         return self._scm.checkout_root
       
    69 
       
    70     def create_patch(self, git_commit):
       
    71         return self._scm.create_patch(git_commit)
       
    72