2011-01-11 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Jan 2011 00:56:54 +0000 (00:56 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Jan 2011 00:56:54 +0000 (00:56 +0000)
        Reviewed by Adam Barth.

        Make webkit-patch support subdirectories for SVN checkouts
        https://bugs.webkit.org/show_bug.cgi?id=52261

        * Scripts/webkitpy/common/checkout/scm.py:
        * Scripts/webkitpy/style_references.py:
        * Scripts/webkitpy/tool/main.py:
        * Scripts/webkitpy/tool/steps/preparechangelog.py:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75575 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/checkout/scm.py
Tools/Scripts/webkitpy/style_references.py
Tools/Scripts/webkitpy/tool/main.py
Tools/Scripts/webkitpy/tool/steps/preparechangelog.py

index e9ccd7a34e09077e4260cc86b73579cb12e6de58..e200f2c5bc46b9b8e0e0a1592d102d6047b015d0 100644 (file)
@@ -1,3 +1,15 @@
+2011-01-11  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Adam Barth.
+
+        Make webkit-patch support subdirectories for SVN checkouts
+        https://bugs.webkit.org/show_bug.cgi?id=52261
+
+        * Scripts/webkitpy/common/checkout/scm.py:
+        * Scripts/webkitpy/style_references.py:
+        * Scripts/webkitpy/tool/main.py:
+        * Scripts/webkitpy/tool/steps/preparechangelog.py:
+
 2011-01-11  Eric Seidel  <eric@webkit.org>
 
         Unreviewed.
index 3f770430ce0a5ed2bf9eb63f393b7a866b4b9583..823438c96dd1f237853dac170ebc713500a85f30 100644 (file)
@@ -52,7 +52,7 @@ def find_checkout_root():
     return None
 
 
-def default_scm():
+def default_scm(patch_directories=None):
     """Return the default SCM object as determined by the CWD and running code.
 
     Returns the default SCM object for the current working directory; if the
@@ -62,10 +62,10 @@ def default_scm():
 
     """
     cwd = os.getcwd()
-    scm_system = detect_scm_system(cwd)
+    scm_system = detect_scm_system(cwd, patch_directories)
     if not scm_system:
         script_directory = os.path.dirname(os.path.abspath(__file__))
-        scm_system = detect_scm_system(script_directory)
+        scm_system = detect_scm_system(script_directory, patch_directories)
         if scm_system:
             log("The current directory (%s) is not a WebKit checkout, using %s" % (cwd, scm_system.checkout_root))
         else:
@@ -73,11 +73,14 @@ def default_scm():
     return scm_system
 
 
-def detect_scm_system(path):
+def detect_scm_system(path, patch_directories=None):
     absolute_path = os.path.abspath(path)
 
+    if patch_directories == []:
+        patch_directories = None
+
     if SVN.in_working_directory(absolute_path):
-        return SVN(cwd=absolute_path)
+        return SVN(cwd=absolute_path, patch_directories=patch_directories)
     
     if Git.in_working_directory(absolute_path):
         return Git(cwd=absolute_path)
@@ -319,9 +322,15 @@ class SVN(SCM):
     svn_server_host = "svn.webkit.org"
     svn_server_realm = "<http://svn.webkit.org:80> Mac OS Forge"
 
-    def __init__(self, cwd):
+    def __init__(self, cwd, patch_directories):
         SCM.__init__(self, cwd)
         self._bogus_dir = None
+        if patch_directories == []:
+            raise ScriptError(script_args=svn_info_args, message='Empty list of patch directories passed to SCM.__init__')
+        elif patch_directories == None:
+            self._patch_directories = [os.path.relpath(cwd, self.checkout_root)]
+        else:
+            self._patch_directories = patch_directories
 
     @staticmethod
     def in_working_directory(path):
@@ -427,7 +436,9 @@ class SVN(SCM):
         return self.run(["svn", "delete", "--force", base], cwd=parent)
 
     def changed_files(self, git_commit=None):
-        return self.run_status_and_extract_filenames(self.status_command(), self._status_regexp("ACDMR"))
+        status_command = ["svn", "status"]
+        status_command.extend(self._patch_directories)
+        return self.run_status_and_extract_filenames(status_command, self._status_regexp("ACDMR"))
 
     def changed_files_for_revision(self, revision):
         # As far as I can tell svn diff --summarize output looks just like svn status output.
@@ -463,10 +474,14 @@ class SVN(SCM):
         return "svn"
 
     # FIXME: This method should be on Checkout.
-    def create_patch(self, git_commit=None, changed_files=[]):
+    def create_patch(self, git_commit=None, changed_files=None):
         """Returns a byte array (str()) representing the patch file.
         Patch files are effectively binary since they may contain
         files of multiple different encodings."""
+        if changed_files == []:
+            return ""
+        elif changed_files == None:
+            changed_files = []
         return self.run([self.script_path("svn-create-patch")] + changed_files,
             cwd=self.checkout_root, return_stderr=False,
             decode_output=False)
index a21e9317bda934d53ec672b049c08727d7a62955..c92bad983e71816d34297a6dc625ece08d4ff221 100644 (file)
@@ -70,5 +70,4 @@ class WebKitCheckout(object):
         return self._scm.checkout_root
 
     def create_patch(self, git_commit, changed_files=None):
-        # FIXME: SCM.create_patch should understand how to handle None.
-        return self._scm.create_patch(git_commit, changed_files=changed_files or [])
+        return self._scm.create_patch(git_commit, changed_files=changed_files)
index cad5a2a5a31b78abdfbee53900a515ec259c75aa..76d5befbec2f76a8437f190cd22c383fbba21146 100755 (executable)
@@ -49,6 +49,7 @@ import webkitpy.tool.commands as commands
 class WebKitPatch(MultiCommandTool):
     global_options = [
         make_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="enable all logging"),
+        make_option("-d", "--directory", action="append", dest="patch_directories", default=[], help="Directory to look at for changed files"),
         make_option("--dry-run", action="store_true", dest="dry_run", default=False, help="do not touch remote servers"),
         make_option("--status-host", action="store", dest="status_host", type="string", help="Hostname (e.g. localhost or commit.webkit.org) where status updates should be posted."),
         make_option("--bot-id", action="store", dest="bot_id", type="string", help="Identifier for this bot (if multiple bots are running for a queue)"),
@@ -82,7 +83,7 @@ class WebKitPatch(MultiCommandTool):
     def scm(self):
         # Lazily initialize SCM to not error-out before command line parsing (or when running non-scm commands).
         if not self._scm:
-            self._scm = default_scm()
+            self._scm = default_scm(self._options.patch_directories)
         return self._scm
 
     def checkout(self):
index 099dfe36e31aab4629a1fbd2105450d004a9db23..392cd3210e3e414abd14d96dd8b6b22df1e5a15f 100644 (file)
@@ -70,6 +70,8 @@ class PrepareChangeLog(AbstractStep):
         if self._tool.scm().supports_local_commits():
             args.append("--merge-base=%s" % self._tool.scm().merge_base(self._options.git_commit))
 
+        args.extend(self._changed_files(state))
+
         try:
             self._tool.executive.run_and_throw_if_fail(args, self._options.quiet)
         except ScriptError, e: