summaryrefslogtreecommitdiffstats
path: root/WebKitTools/Scripts/webkitpy/common/checkout
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-05-26 10:11:43 +0100
committerSteve Block <steveblock@google.com>2010-05-27 11:14:42 +0100
commite78cbe89e6f337f2f1fe40315be88f742b547151 (patch)
treed778000b84a04f24bbad50c7fa66244365e960e9 /WebKitTools/Scripts/webkitpy/common/checkout
parent7b582e96e4e909ed7dba1e07153d20fbddaec3f7 (diff)
downloadexternal_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.zip
external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.gz
external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.bz2
Merge WebKit at r60074: Initial merge by git
Change-Id: I18a2dc5439e36c928351ea829d8fb4e39b062fc7
Diffstat (limited to 'WebKitTools/Scripts/webkitpy/common/checkout')
-rw-r--r--WebKitTools/Scripts/webkitpy/common/checkout/scm.py43
-rw-r--r--WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py18
2 files changed, 43 insertions, 18 deletions
diff --git a/WebKitTools/Scripts/webkitpy/common/checkout/scm.py b/WebKitTools/Scripts/webkitpy/common/checkout/scm.py
index ac9c42e..e68ccfa 100644
--- a/WebKitTools/Scripts/webkitpy/common/checkout/scm.py
+++ b/WebKitTools/Scripts/webkitpy/common/checkout/scm.py
@@ -584,25 +584,32 @@ class Git(SCM):
def revert_files(self, file_paths):
self.run(['git', 'checkout', 'HEAD'] + file_paths)
+ def _get_squash_error_message(self, num_local_commits):
+ working_directory_message = "" if self.working_directory_is_clean() else " and working copy changes"
+ return ("""There are %s local commits%s. Do one of the following:
+ 1) Use --squash or --no-squash
+ 2) git config webkit-patch.squash true/false
+ """ % (num_local_commits, working_directory_message))
+
def should_squash(self, squash):
- if squash is not None:
- # Squash is specified on the command-line.
- return squash
-
- config_squash = Git.read_git_config('webkit-patch.squash')
- if (config_squash and config_squash is not ""):
- return config_squash.lower() == "true"
-
- # Only raise an error if there are actually multiple commits to squash.
- num_local_commits = len(self.local_commits())
- if num_local_commits > 1 or num_local_commits > 0 and not self.working_directory_is_clean():
- working_directory_message = "" if self.working_directory_is_clean() else " and working copy changes"
- raise ScriptError(message="""There are %s local commits%s. Do one of the following:
-1) Use --squash or --no-squash
-2) git config webkit-patch.squash true/false
-""" % (num_local_commits, working_directory_message))
-
- return None
+ if squash is None:
+ config_squash = Git.read_git_config('webkit-patch.squash')
+ if (config_squash and config_squash is not ""):
+ squash = config_squash.lower() == "true"
+ else:
+ # Only raise an error if there are actually multiple commits to squash.
+ num_local_commits = len(self.local_commits())
+ if num_local_commits > 1 or (num_local_commits > 0 and not self.working_directory_is_clean()):
+ raise ScriptError(message=self._get_squash_error_message(num_local_commits))
+
+ if squash and self._svn_branch_has_extra_commits():
+ raise ScriptError(message="Cannot use --squash when HEAD is not fully merged/rebased to %s. "
+ "This branch needs to be synced first." % self.svn_branch_name())
+
+ return squash
+
+ def _svn_branch_has_extra_commits(self):
+ return len(run_command(['git', 'rev-list', '--max-count=1', self.svn_branch_name(), '^head']))
def commit_with_message(self, message, username=None, git_commit=None, squash=None):
# Username is ignored during Git commits.
diff --git a/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py b/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py
index 5a2c094..b6ae388 100644
--- a/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py
@@ -875,6 +875,12 @@ class GitTest(SCMTest):
self.assertTrue(re.search(r'test_file_commit2', svn_log))
self.assertTrue(re.search(r'test_file_commit1', svn_log))
+ def test_commit_with_message_not_synced_squash(self):
+ run_command(['git', 'checkout', '-b', 'my-branch', 'trunk~3'])
+ self._two_local_commits()
+ scm = detect_scm_system(self.git_checkout_path)
+ self.assertRaises(ScriptError, scm.commit_with_message, "another test commit", squash=True)
+
def test_reverse_diff(self):
self._shared_test_reverse_diff()
@@ -937,6 +943,12 @@ class GitTest(SCMTest):
self.assertTrue(re.search(r'test_file_commit2', patch))
self.assertTrue(re.search(r'test_file_commit1', patch))
+ def test_create_patch_not_synced_squash(self):
+ run_command(['git', 'checkout', '-b', 'my-branch', 'trunk~3'])
+ self._two_local_commits()
+ scm = detect_scm_system(self.git_checkout_path)
+ self.assertRaises(ScriptError, scm.create_patch, squash=True)
+
def test_create_binary_patch(self):
# Create a git binary patch and check the contents.
scm = detect_scm_system(self.git_checkout_path)
@@ -1016,6 +1028,12 @@ class GitTest(SCMTest):
self.assertTrue('test_file_commit2' in files)
self.assertTrue('test_file_commit1' in files)
+ def test_changed_files_not_synced_squash(self):
+ run_command(['git', 'checkout', '-b', 'my-branch', 'trunk~3'])
+ self._two_local_commits()
+ scm = detect_scm_system(self.git_checkout_path)
+ self.assertRaises(ScriptError, scm.changed_files, squash=True)
+
def test_changed_files(self):
self._shared_test_changed_files()