[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

eric at webkit.org eric at webkit.org
Thu Oct 29 20:34:20 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 56fba9ec5a3604d240aeb6bc3be8171c7037f7c2
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Sep 25 18:27:53 2009 +0000

    2009-09-25  Eric Seidel  <eric at webkit.org>
    
            Reviewed by Adam Barth.
    
            commit-queue should auto-retry patches which fail to commit due to out of date files
            https://bugs.webkit.org/show_bug.cgi?id=28316
    
            * Scripts/bugzilla-tool:
             - Handle new CheckoutNeedsUpdate exception.
            * Scripts/modules/logging_unittest.py:
             - Call the ScriptError constructor correctly (this test had regressed).
            * Scripts/modules/scm.py:
             - Added the ability to define custom error handlers for run_command
               and added a commit_error_handler which throws CheckoutNeedsUpdate
               instead of ScriptError.
             - Re-ordered ScriptError constructor arguments to make ScriptError("message text") usage possible.
            * Scripts/modules/scm_unittest.py:
             - Added tests of new error handlers.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48762 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index e9938ee..eebd817 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -2,6 +2,25 @@
 
         Reviewed by Adam Barth.
 
+        commit-queue should auto-retry patches which fail to commit due to out of date files
+        https://bugs.webkit.org/show_bug.cgi?id=28316
+
+        * Scripts/bugzilla-tool:
+         - Handle new CheckoutNeedsUpdate exception.
+        * Scripts/modules/logging_unittest.py:
+         - Call the ScriptError constructor correctly (this test had regressed).
+        * Scripts/modules/scm.py:
+         - Added the ability to define custom error handlers for run_command
+           and added a commit_error_handler which throws CheckoutNeedsUpdate
+           instead of ScriptError.
+         - Re-ordered ScriptError constructor arguments to make ScriptError("message text") usage possible.
+        * Scripts/modules/scm_unittest.py:
+         - Added tests of new error handlers.
+
+2009-09-25  Eric Seidel  <eric at webkit.org>
+
+        Reviewed by Adam Barth.
+
         commit-queue should give better feedback when failing a patch
         https://bugs.webkit.org/show_bug.cgi?id=29316
 
diff --git a/WebKitTools/Scripts/bugzilla-tool b/WebKitTools/Scripts/bugzilla-tool
index f909ac8..ec5aa0d 100755
--- a/WebKitTools/Scripts/bugzilla-tool
+++ b/WebKitTools/Scripts/bugzilla-tool
@@ -45,7 +45,7 @@ from modules.bugzilla import Bugzilla, parse_bug_id
 from modules.changelogs import ChangeLog
 from modules.comments import bug_comment_from_commit_text
 from modules.logging import error, log, tee
-from modules.scm import CommitMessage, detect_scm_system, ScriptError
+from modules.scm import CommitMessage, detect_scm_system, ScriptError, CheckoutNeedsUpdate
 from modules.buildbot import BuildBot
 from modules.statusbot import StatusBot
 
@@ -341,6 +341,10 @@ class LandPatchesFromBugs(Command):
 
             if options.close_bug:
                 tool.bugs.close_bug_as_fixed(bug_id, "All reviewed patches have been landed.  Closing bug.")
+        except CheckoutNeedsUpdate, e:
+            log("Commit was rejected because the checkout is out of date.  Please update and try again.")
+            log("You can pass --no-build to skip building/testing after update if you believe the new commits did not affect the results.")
+            error(e)
         except ScriptError, e:
             # Mark the patch as commit-queue- and comment in the bug.
             tool.bugs.reject_patch_from_commit_queue(patch['id'], e.message_with_output())
diff --git a/WebKitTools/Scripts/modules/logging_unittest.py b/WebKitTools/Scripts/modules/logging_unittest.py
index 2dc5946..7d41e56 100644
--- a/WebKitTools/Scripts/modules/logging_unittest.py
+++ b/WebKitTools/Scripts/modules/logging_unittest.py
@@ -54,7 +54,7 @@ class LoggingTest(unittest.TestCase):
         self.assert_log_equals("test", "test\n")
 
         # Test that log() does not throw an exception when passed an object instead of a string.
-        self.assert_log_equals(ScriptError("ScriptError"), "ScriptError\n")
+        self.assert_log_equals(ScriptError(message="ScriptError"), "ScriptError\n")
 
 
 if __name__ == '__main__':
diff --git a/WebKitTools/Scripts/modules/scm.py b/WebKitTools/Scripts/modules/scm.py
index e37b63c..3daecbc 100644
--- a/WebKitTools/Scripts/modules/scm.py
+++ b/WebKitTools/Scripts/modules/scm.py
@@ -78,7 +78,7 @@ class CommitMessage:
 
 
 class ScriptError(Exception):
-    def __init__(self, script_args=None, exit_code=None, message=None, output=None, cwd=None):
+    def __init__(self, message=None, script_args=None, exit_code=None, output=None, cwd=None):
         if not message:
             message = 'Failed to run "%s"' % script_args
             if exit_code:
@@ -99,6 +99,23 @@ class ScriptError(Exception):
             return "%s\n%s" % (self, self.output)
         return str(self)
 
+
+class CheckoutNeedsUpdate(ScriptError):
+    def __init__(self, script_args, exit_code, output, cwd):
+        ScriptError.__init__(self, script_args=script_args, exit_code=exit_code, output=output, cwd=cwd)
+
+
+def default_error_handler(error):
+    raise error
+
+def commit_error_handler(error):
+    if re.search("resource out of date", error.output):
+        raise CheckoutNeedsUpdate(script_args=error.script_args, exit_code=error.exit_code, output=error.output, cwd=error.cwd)
+    default_error_handler(error)
+
+def ignore_error(error):
+    pass
+
 class SCM:
     def __init__(self, cwd, dryrun=False):
         self.cwd = cwd
@@ -106,13 +123,14 @@ class SCM:
         self.dryrun = dryrun
 
     @staticmethod
-    def run_command(args, cwd=None, input=None, raise_on_failure=True, return_exit_code=False):
+    def run_command(args, cwd=None, input=None, error_handler=default_error_handler, return_exit_code=False):
         stdin = subprocess.PIPE if input else None
         process = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd)
         output = process.communicate(input)[0].rstrip()
         exit_code = process.wait()
-        if raise_on_failure and exit_code:
-            raise ScriptError(script_args=args, exit_code=exit_code, output=output, cwd=cwd)
+        if exit_code:
+            script_error = ScriptError(script_args=args, exit_code=exit_code, output=output, cwd=cwd)
+            error_handler(script_error)
         if return_exit_code:
             return exit_code
         return output
@@ -125,7 +143,7 @@ class SCM:
 
     def ensure_clean_working_directory(self, force):
         if not force and not self.working_directory_is_clean():
-            print self.run_command(self.status_command(), raise_on_failure=False)
+            print self.run_command(self.status_command(), error_handler=ignore_error)
             raise ScriptError(message="Working directory has modifications, pass --force-clean or --no-clean to continue.")
         
         log("Cleaning working directory")
@@ -300,7 +318,7 @@ class SVN(SCM):
     @staticmethod
     def commit_success_regexp():
         return "^Committed revision (?P<svn_revision>\d+)\.$"
-    
+
     def svn_version(self):
         if not self.cached_version:
             self.cached_version = self.run_command(['svn', '--version', '--quiet'])
@@ -356,7 +374,7 @@ class SVN(SCM):
         if self.dryrun:
             # Return a string which looks like a commit so that things which parse this output will succeed.
             return "Dry run, no commit.\nCommitted revision 0."
-        return self.run_command(['svn', 'commit', '-m', message])
+        return self.run_command(['svn', 'commit', '-m', message], error_handler=commit_error_handler)
 
     def svn_commit_log(self, svn_revision):
         svn_revision = self.strip_r_from_svn_revision(str(svn_revision))
@@ -388,7 +406,8 @@ class Git(SCM):
     @staticmethod
     def commit_success_regexp():
         return "^Committed r(?P<svn_revision>\d+)$"
-    
+
+
     def discard_local_commits(self):
         self.run_command(['git', 'reset', '--hard', 'trunk'])
     
@@ -448,7 +467,7 @@ class Git(SCM):
 
         # I think this will always fail due to ChangeLogs.
         # FIXME: We need to detec specific failure conditions and handle them.
-        self.run_command(['git', 'revert', '--no-commit', git_commit], raise_on_failure=False)
+        self.run_command(['git', 'revert', '--no-commit', git_commit], error_handler=ignore_error)
 
         # Fix any ChangeLogs if necessary.
         changelog_paths = self.modified_changelogs()
@@ -484,7 +503,7 @@ class Git(SCM):
         if self.dryrun:
             # Return a string which looks like a commit so that things which parse this output will succeed.
             return "Dry run, no remote commit.\nCommitted r0"
-        return self.run_command(['git', 'svn', 'dcommit'])
+        return self.run_command(['git', 'svn', 'dcommit'], error_handler=commit_error_handler)
 
     # This function supports the following argument formats:
     # no args : rev-list trunk..HEAD
diff --git a/WebKitTools/Scripts/modules/scm_unittest.py b/WebKitTools/Scripts/modules/scm_unittest.py
index 9ca308c..58494a0 100644
--- a/WebKitTools/Scripts/modules/scm_unittest.py
+++ b/WebKitTools/Scripts/modules/scm_unittest.py
@@ -35,7 +35,7 @@ import subprocess
 import tempfile
 import unittest
 import urllib
-from modules.scm import detect_scm_system, SCM, ScriptError
+from modules.scm import detect_scm_system, SCM, ScriptError, CheckoutNeedsUpdate, ignore_error, commit_error_handler
 
 
 # Eventually we will want to write tests which work for both scms. (like update_webkit, changed_files, etc.)
@@ -133,6 +133,25 @@ class SCMTest(unittest.TestCase):
         os.mkdir(os.path.dirname(local_scripts_directory))
         os.symlink(webkit_scripts_directory, local_scripts_directory)
 
+    def test_error_handlers(self):
+        git_failure_message="Merge conflict during commit: Your file or directory 'WebCore/ChangeLog' is probably out-of-date: resource out of date; try updating at /usr/local/libexec/git-core//git-svn line 469"
+        svn_failure_message="""svn: Commit failed (details follow):
+svn: File or directory 'ChangeLog' is out of date; try updating
+svn: resource out of date; try updating
+"""
+        command_does_not_exist = ['does_not_exist', 'invalid_option']
+        self.assertRaises(OSError, SCM.run_command, command_does_not_exist)
+        self.assertRaises(OSError, SCM.run_command, command_does_not_exist, error_handler=ignore_error)
+
+        command_returns_non_zero = ['/bin/sh', '--invalid-option']
+        self.assertRaises(ScriptError, SCM.run_command, command_returns_non_zero)
+        self.assertTrue(SCM.run_command(command_returns_non_zero, error_handler=ignore_error))
+
+        self.assertRaises(CheckoutNeedsUpdate, commit_error_handler, ScriptError(output=git_failure_message))
+        self.assertRaises(CheckoutNeedsUpdate, commit_error_handler, ScriptError(output=svn_failure_message))
+        self.assertRaises(ScriptError, commit_error_handler, ScriptError(output='blah blah blah'))
+
+
     # Tests which both GitTest and SVNTest should run.
     # FIXME: There must be a simpler way to add these w/o adding a wrapper method to both subclasses
     def _shared_test_commit_with_message(self):

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list