summaryrefslogtreecommitdiff
path: root/Tools/Scripts/webkitpy/common/checkout
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
commitcd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch)
tree8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Tools/Scripts/webkitpy/common/checkout
parentd11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff)
downloadqtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Tools/Scripts/webkitpy/common/checkout')
-rw-r--r--Tools/Scripts/webkitpy/common/checkout/checkout.py19
-rw-r--r--Tools/Scripts/webkitpy/common/checkout/checkout_mock.py2
-rw-r--r--Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py15
-rw-r--r--Tools/Scripts/webkitpy/common/checkout/scm/git.py5
-rw-r--r--Tools/Scripts/webkitpy/common/checkout/scm/scm.py1
-rw-r--r--Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py10
-rw-r--r--Tools/Scripts/webkitpy/common/checkout/scm/svn.py6
7 files changed, 24 insertions, 34 deletions
diff --git a/Tools/Scripts/webkitpy/common/checkout/checkout.py b/Tools/Scripts/webkitpy/common/checkout/checkout.py
index 08abe6cd8..8f450249c 100644
--- a/Tools/Scripts/webkitpy/common/checkout/checkout.py
+++ b/Tools/Scripts/webkitpy/common/checkout/checkout.py
@@ -1,9 +1,9 @@
# Copyright (c) 2010 Google Inc. All rights reserved.
-#
+#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
-#
+#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
@@ -13,7 +13,7 @@
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
-#
+#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -121,13 +121,13 @@ class Checkout(object):
def modified_non_changelogs(self, git_commit, changed_files=None):
return self._modified_files_matching_predicate(git_commit, lambda path: not self.is_path_to_changelog(path), changed_files=changed_files)
- def commit_message_for_this_commit(self, git_commit, changed_files=None):
+ def commit_message_for_this_commit(self, git_commit, changed_files=None, return_stderr=False):
changelog_paths = self.modified_changelogs(git_commit, changed_files)
if not len(changelog_paths):
raise ScriptError(message="Found no modified ChangeLogs, cannot create a commit message.\n"
"All changes require a ChangeLog. See:\n %s" % urls.contribution_guidelines)
- message_text = self._scm.run([self._scm.script_path('commit-log-editor'), '--print-log'] + changelog_paths, return_stderr=False)
+ message_text = self._scm.run([self._scm.script_path('commit-log-editor'), '--print-log'] + changelog_paths, return_stderr=return_stderr)
return CommitMessage(message_text.splitlines())
def recent_commit_infos_for_files(self, paths):
@@ -150,16 +150,15 @@ class Checkout(object):
def chromium_deps(self):
return DEPS(self._scm.absolute_path(self._filesystem.join("Source", "WebKit", "chromium", "DEPS")))
- def apply_patch(self, patch, force=False):
+ def apply_patch(self, patch):
# It's possible that the patch was not made from the root directory.
# We should detect and handle that case.
# FIXME: Move _scm.script_path here once we get rid of all the dependencies.
- args = [self._scm.script_path('svn-apply')]
+ # --force (continue after errors) is the common case, so we always use it.
+ args = [self._scm.script_path('svn-apply'), "--force"]
if patch.reviewer():
args += ['--reviewer', patch.reviewer().full_name]
- if force:
- args.append('--force')
- self._executive.run_command(args, input=patch.contents())
+ self._executive.run_command(args, input=patch.contents(), cwd=self._scm.checkout_root)
def apply_reverse_diff(self, revision):
self._scm.apply_reverse_diff(revision)
diff --git a/Tools/Scripts/webkitpy/common/checkout/checkout_mock.py b/Tools/Scripts/webkitpy/common/checkout/checkout_mock.py
index 039db1f6a..25b05c33a 100644
--- a/Tools/Scripts/webkitpy/common/checkout/checkout_mock.py
+++ b/Tools/Scripts/webkitpy/common/checkout/checkout_mock.py
@@ -84,7 +84,7 @@ class MockCheckout(object):
def chromium_deps(self):
return MockDEPS()
- def apply_patch(self, patch, force=False):
+ def apply_patch(self, patch):
pass
def apply_reverse_diffs(self, revision):
diff --git a/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py b/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py
index 962364b6c..3b0943247 100644
--- a/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py
+++ b/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py
@@ -42,6 +42,7 @@ from webkitpy.common.system.executive import Executive, ScriptError
from webkitpy.common.system.filesystem import FileSystem # FIXME: This should not be needed.
from webkitpy.common.system.filesystem_mock import MockFileSystem
from webkitpy.common.system.executive_mock import MockExecutive
+from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.thirdparty.mock import Mock
@@ -139,7 +140,9 @@ Second part of this complicated change by me, Tor Arne Vestb\u00f8!
checkout = Checkout(mock_scm)
checkout.modified_changelogs = lambda git_commit, changed_files=None: self.changelogs
- commit_message = checkout.commit_message_for_this_commit(git_commit=None)
+ commit_message = checkout.commit_message_for_this_commit(git_commit=None, return_stderr=True)
+ # Throw away the first line - a warning about unknown VCS root.
+ commit_message.message_lines = commit_message.message_lines[1:]
self.assertEqual(commit_message.message(), self.expected_commit_message)
@@ -250,3 +253,13 @@ class CheckoutTest(unittest.TestCase):
checkout = self._make_checkout()
checkout._scm.checkout_root = "/foo/bar"
self.assertEqual(checkout.chromium_deps()._path, '/foo/bar/Source/WebKit/chromium/DEPS')
+
+ def test_apply_patch(self):
+ checkout = self._make_checkout()
+ checkout._executive = MockExecutive(should_log=True)
+ checkout._scm.script_path = lambda script: script
+ mock_patch = Mock()
+ mock_patch.contents = lambda: "foo"
+ mock_patch.reviewer = lambda: None
+ expected_stderr = "MOCK run_command: ['svn-apply', '--force'], cwd=/mock-checkout\n"
+ OutputCapture().assert_outputs(self, checkout.apply_patch, [mock_patch], expected_stderr=expected_stderr)
diff --git a/Tools/Scripts/webkitpy/common/checkout/scm/git.py b/Tools/Scripts/webkitpy/common/checkout/scm/git.py
index 7c23be056..866b24cc4 100644
--- a/Tools/Scripts/webkitpy/common/checkout/scm/git.py
+++ b/Tools/Scripts/webkitpy/common/checkout/scm/git.py
@@ -434,16 +434,11 @@ class Git(SCM, SVNRepository):
def push_local_commits_to_server(self, username=None, password=None):
dcommit_command = ['git', 'svn', 'dcommit']
- if self.dryrun:
- dcommit_command.append('--dry-run')
if (not username or not password) and not self.has_authorization_for_realm(SVN.svn_server_realm):
raise AuthenticationError(SVN.svn_server_host, prompt_for_password=True)
if username:
dcommit_command.extend(["--username", username])
output = self.run(dcommit_command, error_handler=commit_error_handler, input=password, cwd=self.checkout_root)
- # Return a string which looks like a commit so that things which parse this output will succeed.
- if self.dryrun:
- output += "\nCommitted r0"
return output
# This function supports the following argument formats:
diff --git a/Tools/Scripts/webkitpy/common/checkout/scm/scm.py b/Tools/Scripts/webkitpy/common/checkout/scm/scm.py
index b00470bbb..4b581b17f 100644
--- a/Tools/Scripts/webkitpy/common/checkout/scm/scm.py
+++ b/Tools/Scripts/webkitpy/common/checkout/scm/scm.py
@@ -61,7 +61,6 @@ class SCM:
def __init__(self, cwd, executive=None, filesystem=None):
self.cwd = cwd
self.checkout_root = self.find_checkout_root(self.cwd)
- self.dryrun = False
self._executive = executive or Executive()
self._filesystem = filesystem or FileSystem()
diff --git a/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py b/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py
index ae5ac845c..209bd3510 100644
--- a/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py
+++ b/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py
@@ -757,11 +757,6 @@ Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
commit_text = self.scm.commit_with_message("another test commit", username)
self.assertEqual(self.scm.svn_revision_from_commit_text(commit_text), '6')
- self.scm.dryrun = True
- write_into_file_at_path('test_file', 'still more test content')
- commit_text = self.scm.commit_with_message("yet another test commit", username)
- self.assertEqual(self.scm.svn_revision_from_commit_text(commit_text), '0')
-
def test_commit_in_subdir(self, username=None):
write_into_file_at_path('test_dir/test_file3', 'more test content')
os.chdir("test_dir")
@@ -1216,11 +1211,6 @@ class GitSVNTest(SCMTest):
commit_text = self.scm.commit_with_message("another test commit")
self.assertEqual(self.scm.svn_revision_from_commit_text(commit_text), '6')
- self.scm.dryrun = True
- write_into_file_at_path('test_file', 'still more test content')
- commit_text = self.scm.commit_with_message("yet another test commit")
- self.assertEqual(self.scm.svn_revision_from_commit_text(commit_text), '0')
-
def test_commit_with_message_working_copy_only(self):
write_into_file_at_path('test_file_commit1', 'more test content')
run_command(['git', 'add', 'test_file_commit1'])
diff --git a/Tools/Scripts/webkitpy/common/checkout/scm/svn.py b/Tools/Scripts/webkitpy/common/checkout/scm/svn.py
index cd4e1ea60..3f583a7d3 100644
--- a/Tools/Scripts/webkitpy/common/checkout/scm/svn.py
+++ b/Tools/Scripts/webkitpy/common/checkout/scm/svn.py
@@ -333,12 +333,6 @@ class SVN(SCM, SVNRepository):
if changed_files:
svn_commit_args.extend(changed_files)
- if self.dryrun:
- _log.debug('Would run SVN command: "' + " ".join(svn_commit_args) + '"')
-
- # 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_svn(svn_commit_args, cwd=self.checkout_root, error_handler=commit_error_handler)
def svn_commit_log(self, svn_revision):