[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
eric at webkit.org
eric at webkit.org
Tue Jan 5 23:45:35 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit e2fff50c3710e224c77e2b1fcd6aa107e3a5387e
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Dec 9 07:51:39 2009 +0000
2009-12-08 Eric Seidel <eric at webkit.org>
Reviewed by Adam Barth.
run_command and ScriptError should move into processutils.py
https://bugs.webkit.org/show_bug.cgi?id=32305
Turns out there are a zillion callers to run_command.
* Scripts/modules/commands/download.py:
* Scripts/modules/commands/early_warning_system.py:
* Scripts/modules/commands/queues.py:
* Scripts/modules/landingsequence.py:
* Scripts/modules/logging_unittest.py:
* Scripts/modules/processutils.py:
* Scripts/modules/scm.py:
* Scripts/modules/scm_unittest.py:
* Scripts/modules/workqueue.py:
* Scripts/modules/workqueue_unittest.py:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51888 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 5cb1f3d..b6931df 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,23 @@
+2009-12-08 Eric Seidel <eric at webkit.org>
+
+ Reviewed by Adam Barth.
+
+ run_command and ScriptError should move into processutils.py
+ https://bugs.webkit.org/show_bug.cgi?id=32305
+
+ Turns out there are a zillion callers to run_command.
+
+ * Scripts/modules/commands/download.py:
+ * Scripts/modules/commands/early_warning_system.py:
+ * Scripts/modules/commands/queues.py:
+ * Scripts/modules/landingsequence.py:
+ * Scripts/modules/logging_unittest.py:
+ * Scripts/modules/processutils.py:
+ * Scripts/modules/scm.py:
+ * Scripts/modules/scm_unittest.py:
+ * Scripts/modules/workqueue.py:
+ * Scripts/modules/workqueue_unittest.py:
+
2009-12-08 Kevin Watters <kevinwatters at gmail.com>
Reviewed by Kevin Ollivier.
diff --git a/WebKitTools/Scripts/modules/commands/download.py b/WebKitTools/Scripts/modules/commands/download.py
index 2d5e301..3bfa55f 100644
--- a/WebKitTools/Scripts/modules/commands/download.py
+++ b/WebKitTools/Scripts/modules/commands/download.py
@@ -40,7 +40,7 @@ from modules.grammar import pluralize
from modules.landingsequence import LandingSequence, ConditionalLandingSequence
from modules.logging import error, log
from modules.multicommandtool import Command
-from modules.scm import ScriptError
+from modules.processutils import ScriptError
class BuildSequence(ConditionalLandingSequence):
diff --git a/WebKitTools/Scripts/modules/commands/early_warning_system.py b/WebKitTools/Scripts/modules/commands/early_warning_system.py
index a3f7646..75d7378 100644
--- a/WebKitTools/Scripts/modules/commands/early_warning_system.py
+++ b/WebKitTools/Scripts/modules/commands/early_warning_system.py
@@ -28,7 +28,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from modules.commands.queues import AbstractReviewQueue
-from modules.scm import ScriptError
+from modules.processutils import ScriptError
from modules.webkitport import WebKitPort
class AbstractEarlyWarningSystem(AbstractReviewQueue):
diff --git a/WebKitTools/Scripts/modules/commands/queues.py b/WebKitTools/Scripts/modules/commands/queues.py
index 6aefd0f..5f70ce1 100644
--- a/WebKitTools/Scripts/modules/commands/queues.py
+++ b/WebKitTools/Scripts/modules/commands/queues.py
@@ -38,8 +38,7 @@ from modules.landingsequence import LandingSequence, ConditionalLandingSequence,
from modules.logging import error, log
from modules.multicommandtool import Command
from modules.patchcollection import PatchCollection, PersistentPatchCollection, PersistentPatchCollectionDelegate
-from modules.processutils import run_and_throw_if_fail
-from modules.scm import ScriptError
+from modules.processutils import run_and_throw_if_fail, ScriptError
from modules.statusbot import StatusBot
from modules.workqueue import WorkQueue, WorkQueueDelegate
diff --git a/WebKitTools/Scripts/modules/landingsequence.py b/WebKitTools/Scripts/modules/landingsequence.py
index eddb539..72c2959 100644
--- a/WebKitTools/Scripts/modules/landingsequence.py
+++ b/WebKitTools/Scripts/modules/landingsequence.py
@@ -30,7 +30,8 @@
from modules.comments import bug_comment_from_commit_text
from modules.logging import log
-from modules.scm import ScriptError, CheckoutNeedsUpdate
+from modules.processutils import ScriptError
+from modules.scm import CheckoutNeedsUpdate
from modules.webkitport import WebKitPort
from modules.workqueue import WorkQueue
diff --git a/WebKitTools/Scripts/modules/logging_unittest.py b/WebKitTools/Scripts/modules/logging_unittest.py
index 7d41e56..0e7ef79 100644
--- a/WebKitTools/Scripts/modules/logging_unittest.py
+++ b/WebKitTools/Scripts/modules/logging_unittest.py
@@ -33,7 +33,7 @@ import tempfile
import unittest
from modules.logging import *
-from modules.scm import ScriptError
+from modules.processutils import ScriptError
class LoggingTest(unittest.TestCase):
diff --git a/WebKitTools/Scripts/modules/processutils.py b/WebKitTools/Scripts/modules/processutils.py
index 68cf215..7a681bf 100644
--- a/WebKitTools/Scripts/modules/processutils.py
+++ b/WebKitTools/Scripts/modules/processutils.py
@@ -33,7 +33,36 @@ import subprocess
import sys
from modules.logging import tee
-from modules.scm import ScriptError
+
+# FIXME: These methods could all be unified into one!
+
+class ScriptError(Exception):
+ 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:
+ message += " exit_code: %d" % exit_code
+ if cwd:
+ message += " cwd: %s" % cwd
+
+ Exception.__init__(self, message)
+ self.script_args = script_args # 'args' is already used by Exception
+ self.exit_code = exit_code
+ self.output = output
+ self.cwd = cwd
+
+ def message_with_output(self, output_limit=500):
+ if self.output:
+ if output_limit and len(self.output) > output_limit:
+ return "%s\nLast %s characters of output:\n%s" % (self, output_limit, self.output[-output_limit:])
+ return "%s\n%s" % (self, self.output)
+ return str(self)
+
+def default_error_handler(error):
+ raise error
+
+def ignore_error(error):
+ pass
def run_command_with_teed_output(args, teed_output):
child_process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
@@ -46,6 +75,27 @@ def run_command_with_teed_output(args, teed_output):
return child_process.poll()
teed_output.write(output_line)
+def run_command(args, cwd=None, input=None, error_handler=default_error_handler, return_exit_code=False, return_stderr=True):
+ if hasattr(input, 'read'): # Check if the input is a file.
+ stdin = input
+ string_to_communicate = None
+ else:
+ stdin = subprocess.PIPE if input else None
+ string_to_communicate = input
+ if return_stderr:
+ stderr = subprocess.STDOUT
+ else:
+ stderr = None
+ process = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr, cwd=cwd)
+ output = process.communicate(string_to_communicate)[0]
+ exit_code = process.wait()
+ 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
+
def run_and_throw_if_fail(args, quiet=False):
# Cache the child's output locally so it can be used for error reports.
child_out_file = StringIO.StringIO()
diff --git a/WebKitTools/Scripts/modules/scm.py b/WebKitTools/Scripts/modules/scm.py
index d0db984..a09236c 100644
--- a/WebKitTools/Scripts/modules/scm.py
+++ b/WebKitTools/Scripts/modules/scm.py
@@ -36,6 +36,7 @@ import subprocess
# Import WebKit-specific modules.
from modules.changelogs import ChangeLog
from modules.logging import error, log
+from modules.processutils import run_command, ScriptError, default_error_handler, ignore_error
def detect_scm_system(path):
if SVN.in_working_directory(path):
@@ -78,44 +79,16 @@ class CommitMessage:
return "\n".join(self.message_lines) + "\n"
-class ScriptError(Exception):
- 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:
- message += " exit_code: %d" % exit_code
- if cwd:
- message += " cwd: %s" % cwd
-
- Exception.__init__(self, message)
- self.script_args = script_args # 'args' is already used by Exception
- self.exit_code = exit_code
- self.output = output
- self.cwd = cwd
-
- def message_with_output(self, output_limit=500):
- if self.output:
- if output_limit and len(self.output) > output_limit:
- return "%s\nLast %s characters of output:\n%s" % (self, output_limit, self.output[-output_limit:])
- 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):
@@ -123,28 +96,6 @@ class SCM:
self.checkout_root = self.find_checkout_root(self.cwd)
self.dryrun = dryrun
- @staticmethod
- def run_command(args, cwd=None, input=None, error_handler=default_error_handler, return_exit_code=False, return_stderr=True):
- if hasattr(input, 'read'): # Check if the input is a file.
- stdin = input
- string_to_communicate = None
- else:
- stdin = subprocess.PIPE if input else None
- string_to_communicate = input
- if return_stderr:
- stderr = subprocess.STDOUT
- else:
- stderr = None
- process = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr, cwd=cwd)
- output = process.communicate(string_to_communicate)[0]
- exit_code = process.wait()
- 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
-
def scripts_directory(self):
return os.path.join(self.checkout_root, "WebKitTools", "Scripts")
@@ -153,7 +104,7 @@ class SCM:
def ensure_clean_working_directory(self, force_clean):
if not force_clean and not self.working_directory_is_clean():
- print self.run_command(self.status_command(), error_handler=ignore_error)
+ print 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")
@@ -179,11 +130,11 @@ class SCM:
if force:
args.append('--force')
- self.run_command(args, input=curl_process.stdout)
+ run_command(args, input=curl_process.stdout)
def run_status_and_extract_filenames(self, status_command, status_regexp):
filenames = []
- for line in self.run_command(status_command).splitlines():
+ for line in run_command(status_command).splitlines():
match = re.search(status_regexp, line)
if not match:
continue
@@ -321,7 +272,7 @@ class SVN(SCM):
@classmethod
def value_from_svn_info(cls, path, field_name):
svn_info_args = ['svn', 'info', path]
- info_output = cls.run_command(svn_info_args).rstrip()
+ info_output = run_command(svn_info_args).rstrip()
match = re.search("^%s: (?P<value>.+)$" % field_name, info_output, re.MULTILINE)
if not match:
raise ScriptError(script_args=svn_info_args, message='svn info did not contain a %s.' % field_name)
@@ -349,15 +300,15 @@ class SVN(SCM):
def svn_version(self):
if not self.cached_version:
- self.cached_version = self.run_command(['svn', '--version', '--quiet'])
+ self.cached_version = run_command(['svn', '--version', '--quiet'])
return self.cached_version
def working_directory_is_clean(self):
- return self.run_command(['svn', 'diff']) == ""
+ return run_command(['svn', 'diff']) == ""
def clean_working_directory(self):
- self.run_command(['svn', 'revert', '-R', '.'])
+ run_command(['svn', 'revert', '-R', '.'])
def status_command(self):
return ['svn', 'status']
@@ -377,10 +328,10 @@ class SVN(SCM):
return "svn"
def create_patch(self):
- return self.run_command(self.script_path("svn-create-patch"), cwd=self.checkout_root, return_stderr=False)
+ return run_command(self.script_path("svn-create-patch"), cwd=self.checkout_root, return_stderr=False)
def diff_for_revision(self, revision):
- return self.run_command(['svn', 'diff', '-c', str(revision)])
+ return run_command(['svn', 'diff', '-c', str(revision)])
def _repository_url(self):
return self.value_from_svn_info(self.checkout_root, 'URL')
@@ -390,20 +341,20 @@ class SVN(SCM):
svn_merge_args = ['svn', 'merge', '--non-interactive', '-c', '-%s' % revision, self._repository_url()]
log("WARNING: svn merge has been known to take more than 10 minutes to complete. It is recommended you use git for rollouts.")
log("Running '%s'" % " ".join(svn_merge_args))
- self.run_command(svn_merge_args)
+ run_command(svn_merge_args)
def revert_files(self, file_paths):
- self.run_command(['svn', 'revert'] + file_paths)
+ run_command(['svn', 'revert'] + file_paths)
def commit_with_message(self, message):
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], error_handler=commit_error_handler)
+ return 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))
- return self.run_command(['svn', 'log', '--non-interactive', '--revision', svn_revision]);
+ return run_command(['svn', 'log', '--non-interactive', '--revision', svn_revision]);
def last_svn_commit_log(self):
# BASE is the checkout revision, HEAD is the remote repository revision
@@ -417,12 +368,12 @@ class Git(SCM):
@classmethod
def in_working_directory(cls, path):
- return cls.run_command(['git', 'rev-parse', '--is-inside-work-tree'], cwd=path, error_handler=ignore_error).rstrip() == "true"
+ return run_command(['git', 'rev-parse', '--is-inside-work-tree'], cwd=path, error_handler=ignore_error).rstrip() == "true"
@classmethod
def find_checkout_root(cls, path):
# "git rev-parse --show-cdup" would be another way to get to the root
- (checkout_root, dot_git) = os.path.split(cls.run_command(['git', 'rev-parse', '--git-dir'], cwd=path))
+ (checkout_root, dot_git) = os.path.split(run_command(['git', 'rev-parse', '--git-dir'], cwd=path))
# If we were using 2.6 # checkout_root = os.path.relpath(checkout_root, path)
if not os.path.isabs(checkout_root): # Sometimes git returns relative paths
checkout_root = os.path.join(path, checkout_root)
@@ -434,23 +385,23 @@ class Git(SCM):
def discard_local_commits(self):
- self.run_command(['git', 'reset', '--hard', 'trunk'])
+ run_command(['git', 'reset', '--hard', 'trunk'])
def local_commits(self):
- return self.run_command(['git', 'log', '--pretty=oneline', 'HEAD...trunk']).splitlines()
+ return run_command(['git', 'log', '--pretty=oneline', 'HEAD...trunk']).splitlines()
def rebase_in_progress(self):
return os.path.exists(os.path.join(self.checkout_root, '.git/rebase-apply'))
def working_directory_is_clean(self):
- return self.run_command(['git', 'diff-index', 'HEAD']) == ""
+ return run_command(['git', 'diff-index', 'HEAD']) == ""
def clean_working_directory(self):
# Could run git clean here too, but that wouldn't match working_directory_is_clean
- self.run_command(['git', 'reset', '--hard', 'HEAD'])
+ run_command(['git', 'reset', '--hard', 'HEAD'])
# Aborting rebase even though this does not match working_directory_is_clean
if self.rebase_in_progress():
- self.run_command(['git', 'rebase', '--abort'])
+ run_command(['git', 'rebase', '--abort'])
def status_command(self):
return ['git', 'status']
@@ -468,12 +419,12 @@ class Git(SCM):
return "git"
def create_patch(self):
- return self.run_command(['git', 'diff', '--binary', 'HEAD'])
+ return run_command(['git', 'diff', '--binary', 'HEAD'])
@classmethod
def git_commit_from_svn_revision(cls, revision):
# git svn find-rev always exits 0, even when the revision is not found.
- return cls.run_command(['git', 'svn', 'find-rev', 'r%s' % revision]).rstrip()
+ return run_command(['git', 'svn', 'find-rev', 'r%s' % revision]).rstrip()
def diff_for_revision(self, revision):
git_commit = self.git_commit_from_svn_revision(revision)
@@ -487,15 +438,15 @@ 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], error_handler=ignore_error)
+ run_command(['git', 'revert', '--no-commit', git_commit], error_handler=ignore_error)
# Fix any ChangeLogs if necessary.
changelog_paths = self.modified_changelogs()
if len(changelog_paths):
- self.run_command([self.script_path('resolve-ChangeLogs')] + changelog_paths)
+ run_command([self.script_path('resolve-ChangeLogs')] + changelog_paths)
def revert_files(self, file_paths):
- self.run_command(['git', 'checkout', 'HEAD'] + file_paths)
+ run_command(['git', 'checkout', 'HEAD'] + file_paths)
def commit_with_message(self, message):
self.commit_locally_with_message(message)
@@ -503,27 +454,27 @@ class Git(SCM):
def svn_commit_log(self, svn_revision):
svn_revision = self.strip_r_from_svn_revision(svn_revision)
- return self.run_command(['git', 'svn', 'log', '-r', svn_revision])
+ return run_command(['git', 'svn', 'log', '-r', svn_revision])
def last_svn_commit_log(self):
- return self.run_command(['git', 'svn', 'log', '--limit=1'])
+ return run_command(['git', 'svn', 'log', '--limit=1'])
# Git-specific methods:
def create_patch_from_local_commit(self, commit_id):
- return self.run_command(['git', 'diff', '--binary', commit_id + "^.." + commit_id])
+ return run_command(['git', 'diff', '--binary', commit_id + "^.." + commit_id])
def create_patch_since_local_commit(self, commit_id):
- return self.run_command(['git', 'diff', '--binary', commit_id])
+ return run_command(['git', 'diff', '--binary', commit_id])
def commit_locally_with_message(self, message):
- self.run_command(['git', 'commit', '--all', '-F', '-'], input=message)
+ run_command(['git', 'commit', '--all', '-F', '-'], input=message)
def push_local_commits_to_server(self):
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'], error_handler=commit_error_handler)
+ return run_command(['git', 'svn', 'dcommit'], error_handler=commit_error_handler)
# This function supports the following argument formats:
# no args : rev-list trunk..HEAD
@@ -540,14 +491,14 @@ class Git(SCM):
if '...' in commitish:
raise ScriptError(message="'...' is not supported (found in '%s'). Did you mean '..'?" % commitish)
elif '..' in commitish:
- commit_ids += reversed(self.run_command(['git', 'rev-list', commitish]).splitlines())
+ commit_ids += reversed(run_command(['git', 'rev-list', commitish]).splitlines())
else:
# Turn single commits or branch or tag names into commit ids.
- commit_ids += self.run_command(['git', 'rev-parse', '--revs-only', commitish]).splitlines()
+ commit_ids += run_command(['git', 'rev-parse', '--revs-only', commitish]).splitlines()
return commit_ids
def commit_message_for_local_commit(self, commit_id):
- commit_lines = self.run_command(['git', 'cat-file', 'commit', commit_id]).splitlines()
+ commit_lines = run_command(['git', 'cat-file', 'commit', commit_id]).splitlines()
# Skip the git headers.
first_line_after_headers = 0
@@ -558,4 +509,4 @@ class Git(SCM):
return CommitMessage(commit_lines[first_line_after_headers:])
def files_changed_summary_for_commit(self, commit_id):
- return self.run_command(['git', 'diff-tree', '--shortstat', '--no-commit-id', commit_id])
+ return run_command(['git', 'diff-tree', '--shortstat', '--no-commit-id', commit_id])
diff --git a/WebKitTools/Scripts/modules/scm_unittest.py b/WebKitTools/Scripts/modules/scm_unittest.py
index f0c84af..f3f6960 100644
--- a/WebKitTools/Scripts/modules/scm_unittest.py
+++ b/WebKitTools/Scripts/modules/scm_unittest.py
@@ -38,15 +38,13 @@ import unittest
import urllib
from datetime import date
-from modules.scm import detect_scm_system, SCM, ScriptError, CheckoutNeedsUpdate, ignore_error, commit_error_handler
-
+from modules.scm import detect_scm_system, SCM, CheckoutNeedsUpdate, commit_error_handler
+from modules.processutils import run_command, ignore_error, ScriptError
# Eventually we will want to write tests which work for both scms. (like update_webkit, changed_files, etc.)
# Perhaps through some SCMTest base-class which both SVNTest and GitTest inherit from.
-def run(args, cwd=None):
- return SCM.run_command(args, cwd=cwd)
-
+# FIXME: This should be unified into one of the processutils.py commands!
def run_silent(args, cwd=None):
process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
process.communicate() # ignore output
@@ -75,26 +73,26 @@ class SVNTestRepository:
test_file.write("test1")
test_file.flush()
- run(['svn', 'add', 'test_file'])
- run(['svn', 'commit', '--quiet', '--message', 'initial commit'])
+ run_command(['svn', 'add', 'test_file'])
+ run_command(['svn', 'commit', '--quiet', '--message', 'initial commit'])
test_file.write("test2")
test_file.flush()
- run(['svn', 'commit', '--quiet', '--message', 'second commit'])
+ run_command(['svn', 'commit', '--quiet', '--message', 'second commit'])
test_file.write("test3\n")
test_file.flush()
- run(['svn', 'commit', '--quiet', '--message', 'third commit'])
+ run_command(['svn', 'commit', '--quiet', '--message', 'third commit'])
test_file.write("test4\n")
test_file.close()
- run(['svn', 'commit', '--quiet', '--message', 'fourth commit'])
+ run_command(['svn', 'commit', '--quiet', '--message', 'fourth commit'])
# svn does not seem to update after commit as I would expect.
- run(['svn', 'update'])
+ run_command(['svn', 'update'])
@classmethod
def setup(cls, test_object):
@@ -103,18 +101,18 @@ class SVNTestRepository:
test_object.svn_repo_url = "file://%s" % test_object.svn_repo_path # Not sure this will work on windows
# git svn complains if we don't pass --pre-1.5-compatible, not sure why:
# Expected FS format '2'; found format '3' at /usr/local/libexec/git-core//git-svn line 1477
- run(['svnadmin', 'create', '--pre-1.5-compatible', test_object.svn_repo_path])
+ run_command(['svnadmin', 'create', '--pre-1.5-compatible', test_object.svn_repo_path])
# Create a test svn checkout
test_object.svn_checkout_path = tempfile.mkdtemp(suffix="svn_test_checkout")
- run(['svn', 'checkout', '--quiet', test_object.svn_repo_url, test_object.svn_checkout_path])
+ run_command(['svn', 'checkout', '--quiet', test_object.svn_repo_url, test_object.svn_checkout_path])
cls._setup_test_commits(test_object)
@classmethod
def tear_down(cls, test_object):
- run(['rm', '-rf', test_object.svn_repo_path])
- run(['rm', '-rf', test_object.svn_checkout_path])
+ run_command(['rm', '-rf', test_object.svn_repo_path])
+ run_command(['rm', '-rf', test_object.svn_checkout_path])
# For testing the SCM baseclass directly.
class SCMClassTests(unittest.TestCase):
@@ -126,20 +124,20 @@ class SCMClassTests(unittest.TestCase):
def test_run_command_with_pipe(self):
input_process = subprocess.Popen(['echo', 'foo\nbar'], stdout=subprocess.PIPE, stderr=self.dev_null)
- self.assertEqual(SCM.run_command(['grep', 'bar'], input=input_process.stdout), "bar\n")
+ self.assertEqual(run_command(['grep', 'bar'], input=input_process.stdout), "bar\n")
# Test the non-pipe case too:
- self.assertEqual(SCM.run_command(['grep', 'bar'], input="foo\nbar"), "bar\n")
+ self.assertEqual(run_command(['grep', 'bar'], input="foo\nbar"), "bar\n")
command_returns_non_zero = ['/bin/sh', '--invalid-option']
# Test when the input pipe process fails.
input_process = subprocess.Popen(command_returns_non_zero, stdout=subprocess.PIPE, stderr=self.dev_null)
self.assertTrue(input_process.poll() != 0)
- self.assertRaises(ScriptError, SCM.run_command, ['grep', 'bar'], input=input_process.stdout)
+ self.assertRaises(ScriptError, run_command, ['grep', 'bar'], input=input_process.stdout)
# Test when the run_command process fails.
input_process = subprocess.Popen(['echo', 'foo\nbar'], stdout=subprocess.PIPE, stderr=self.dev_null) # grep shows usage and calls exit(2) when called w/o arguments.
- self.assertRaises(ScriptError, SCM.run_command, command_returns_non_zero, input=input_process.stdout)
+ self.assertRaises(ScriptError, run_command, command_returns_non_zero, input=input_process.stdout)
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"
@@ -148,13 +146,13 @@ 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)
+ self.assertRaises(OSError, run_command, command_does_not_exist)
+ self.assertRaises(OSError, 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.assertRaises(ScriptError, run_command, command_returns_non_zero)
# Check if returns error text:
- self.assertTrue(SCM.run_command(command_returns_non_zero, error_handler=ignore_error))
+ self.assertTrue(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))
@@ -365,14 +363,14 @@ class SVNTest(SCMTest):
* scm_unittest.py:
"""
write_into_file_at_path('ChangeLog', first_entry)
- run(['svn', 'add', 'ChangeLog'])
- run(['svn', 'commit', '--quiet', '--message', 'ChangeLog commit'])
+ run_command(['svn', 'add', 'ChangeLog'])
+ run_command(['svn', 'commit', '--quiet', '--message', 'ChangeLog commit'])
# Patch files were created against just 'first_entry'.
# Add a second commit to make svn-apply have to apply the patches with fuzz.
changelog_contents = "%s\n%s" % (intermediate_entry, first_entry)
write_into_file_at_path('ChangeLog', changelog_contents)
- run(['svn', 'commit', '--quiet', '--message', 'Intermediate commit'])
+ run_command(['svn', 'commit', '--quiet', '--message', 'Intermediate commit'])
self._setup_webkittools_scripts_symlink(self.scm)
self.scm.apply_patch(self._create_patch(one_line_overlap_patch))
@@ -397,7 +395,7 @@ class SVNTest(SCMTest):
os.mkdir(test_dir_path)
test_file_path = os.path.join(test_dir_path, 'test_file2')
write_into_file_at_path(test_file_path, 'test content')
- run(['svn', 'add', 'test_dir'])
+ run_command(['svn', 'add', 'test_dir'])
# create_patch depends on 'svn-create-patch', so make a dummy version.
scripts_path = os.path.join(self.svn_checkout_path, 'WebKitTools', 'Scripts')
@@ -442,13 +440,13 @@ Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
def test_apply_svn_patch(self):
scm = detect_scm_system(self.svn_checkout_path)
- patch = self._create_patch(run(['svn', 'diff', '-r4:3']))
+ patch = self._create_patch(run_command(['svn', 'diff', '-r4:3']))
self._setup_webkittools_scripts_symlink(scm)
scm.apply_patch(patch)
def test_apply_svn_patch_force(self):
scm = detect_scm_system(self.svn_checkout_path)
- patch = self._create_patch(run(['svn', 'diff', '-r2:4']))
+ patch = self._create_patch(run_command(['svn', 'diff', '-r2:4']))
self._setup_webkittools_scripts_symlink(scm)
self.assertRaises(ScriptError, scm.apply_patch, patch, force=True)
@@ -477,7 +475,7 @@ class GitTest(SCMTest):
run_silent(['git', 'svn', '--quiet', 'clone', self.svn_repo_url, self.git_checkout_path])
def _tear_down_git_clone_of_svn_repository(self):
- run(['rm', '-rf', self.git_checkout_path])
+ run_command(['rm', '-rf', self.git_checkout_path])
def setUp(self):
SVNTestRepository.setup(self)
@@ -497,11 +495,11 @@ class GitTest(SCMTest):
def test_rebase_in_progress(self):
svn_test_file = os.path.join(self.svn_checkout_path, 'test_file')
write_into_file_at_path(svn_test_file, "svn_checkout")
- run(['svn', 'commit', '--message', 'commit to conflict with git commit'], cwd=self.svn_checkout_path)
+ run_command(['svn', 'commit', '--message', 'commit to conflict with git commit'], cwd=self.svn_checkout_path)
git_test_file = os.path.join(self.git_checkout_path, 'test_file')
write_into_file_at_path(git_test_file, "git_checkout")
- run(['git', 'commit', '-a', '-m', 'commit to be thrown away by rebase abort'])
+ run_command(['git', 'commit', '-a', '-m', 'commit to be thrown away by rebase abort'])
# --quiet doesn't make git svn silent, so use run_silent to redirect output
self.assertRaises(ScriptError, run_silent, ['git', 'svn', '--quiet', 'rebase']) # Will fail due to a conflict leaving us mid-rebase.
@@ -533,19 +531,19 @@ class GitTest(SCMTest):
actual_commits = scm.commit_ids_from_commitish_arguments([commit_range])
expected_commits = []
- expected_commits += reversed(run(['git', 'rev-list', commit_range]).splitlines())
+ expected_commits += reversed(run_command(['git', 'rev-list', commit_range]).splitlines())
self.assertEqual(actual_commits, expected_commits)
def test_apply_git_patch(self):
scm = detect_scm_system(self.git_checkout_path)
- patch = self._create_patch(run(['git', 'diff', 'HEAD..HEAD^']))
+ patch = self._create_patch(run_command(['git', 'diff', 'HEAD..HEAD^']))
self._setup_webkittools_scripts_symlink(scm)
scm.apply_patch(patch)
def test_apply_git_patch_force(self):
scm = detect_scm_system(self.git_checkout_path)
- patch = self._create_patch(run(['git', 'diff', 'HEAD~2..HEAD']))
+ patch = self._create_patch(run_command(['git', 'diff', 'HEAD~2..HEAD']))
self._setup_webkittools_scripts_symlink(scm)
self.assertRaises(ScriptError, scm.apply_patch, patch, force=True)
@@ -568,21 +566,21 @@ class GitTest(SCMTest):
test_file_path = os.path.join(self.git_checkout_path, test_file_name)
file_contents = ''.join(map(chr, range(256)))
write_into_file_at_path(test_file_path, file_contents)
- run(['git', 'add', test_file_name])
+ run_command(['git', 'add', test_file_name])
patch = scm.create_patch()
self.assertTrue(re.search(r'\nliteral 0\n', patch))
self.assertTrue(re.search(r'\nliteral 256\n', patch))
# Check if we can apply the created patch.
- run(['git', 'rm', '-f', test_file_name])
+ run_command(['git', 'rm', '-f', test_file_name])
self._setup_webkittools_scripts_symlink(scm)
self.scm.apply_patch(self._create_patch(patch))
self.assertEqual(file_contents, read_from_path(test_file_path))
# Check if we can create a patch from a local commit.
write_into_file_at_path(test_file_path, file_contents)
- run(['git', 'add', test_file_name])
- run(['git', 'commit', '-m', 'binary diff'])
+ run_command(['git', 'add', test_file_name])
+ run_command(['git', 'commit', '-m', 'binary diff'])
patch_from_local_commit = scm.create_patch_from_local_commit('HEAD')
self.assertTrue(re.search(r'\nliteral 0\n', patch_from_local_commit))
self.assertTrue(re.search(r'\nliteral 256\n', patch_from_local_commit))
diff --git a/WebKitTools/Scripts/modules/workqueue.py b/WebKitTools/Scripts/modules/workqueue.py
index 8cd40bc..51af47c 100644
--- a/WebKitTools/Scripts/modules/workqueue.py
+++ b/WebKitTools/Scripts/modules/workqueue.py
@@ -35,7 +35,7 @@ import traceback
from datetime import datetime, timedelta
from modules.logging import log, OutputTee
-from modules.scm import ScriptError
+from modules.processutils import ScriptError
from modules.statusbot import StatusBot
class WorkQueueDelegate:
diff --git a/WebKitTools/Scripts/modules/workqueue_unittest.py b/WebKitTools/Scripts/modules/workqueue_unittest.py
index 1e9c8ad..04c74c8 100644
--- a/WebKitTools/Scripts/modules/workqueue_unittest.py
+++ b/WebKitTools/Scripts/modules/workqueue_unittest.py
@@ -32,7 +32,7 @@ import shutil
import tempfile
import unittest
-from modules.scm import ScriptError
+from modules.processutils import ScriptError
from modules.workqueue import WorkQueue, WorkQueueDelegate
class LoggingDelegate(WorkQueueDelegate):
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list