| Index: sky/tools/webkitpy/common/checkout/scm/scm_unittest.py
|
| diff --git a/sky/tools/webkitpy/common/checkout/scm/scm_unittest.py b/sky/tools/webkitpy/common/checkout/scm/scm_unittest.py
|
| index 67b59eb3005294268f5b2a2bc763873c45e77b21..a8de9ed25a885877405343f1e9ec541b59b230c2 100644
|
| --- a/sky/tools/webkitpy/common/checkout/scm/scm_unittest.py
|
| +++ b/sky/tools/webkitpy/common/checkout/scm/scm_unittest.py
|
| @@ -40,7 +40,6 @@ from webkitpy.common.system.filesystem_mock import MockFileSystem
|
| from webkitpy.common.checkout.scm.detection import detect_scm_system
|
| from webkitpy.common.checkout.scm.git import Git, AmbiguousCommitError
|
| from webkitpy.common.checkout.scm.scm import SCM
|
| -from webkitpy.common.checkout.scm.svn import SVN
|
|
|
|
|
| # We cache the mock SVN repo so that we don't create it again for each call to an SVNTest or GitTest test_ method.
|
| @@ -254,55 +253,6 @@ class SCMTestBase(unittest.TestCase):
|
| self.assertIn('moved_dir/another_added_file', self.scm._added_files())
|
|
|
|
|
| -class SVNTest(SCMTestBase):
|
| - def setUp(self):
|
| - super(SVNTest, self).setUp()
|
| - self._set_up_svn_checkout()
|
| - self._chdir(self.svn_checkout_path)
|
| - self.scm = detect_scm_system(self.svn_checkout_path)
|
| - self.scm.svn_server_realm = None
|
| -
|
| - def tearDown(self):
|
| - super(SVNTest, self).tearDown()
|
| - self._tear_down_svn_checkout()
|
| -
|
| - def test_detect_scm_system_relative_url(self):
|
| - scm = detect_scm_system(".")
|
| - # I wanted to assert that we got the right path, but there was some
|
| - # crazy magic with temp folder names that I couldn't figure out.
|
| - self.assertTrue(scm.checkout_root)
|
| -
|
| - def test_detection(self):
|
| - self.assertEqual(self.scm.display_name(), "svn")
|
| - self.assertEqual(self.scm.supports_local_commits(), False)
|
| -
|
| - def test_add_recursively(self):
|
| - self._shared_test_add_recursively()
|
| -
|
| - def test_delete(self):
|
| - self._chdir(self.svn_checkout_path)
|
| - self.scm.delete("test_file")
|
| - self.assertIn("test_file", self.scm._deleted_files())
|
| -
|
| - def test_delete_list(self):
|
| - self._chdir(self.svn_checkout_path)
|
| - self.scm.delete_list(["test_file", "test_file2"])
|
| - self.assertIn("test_file", self.scm._deleted_files())
|
| - self.assertIn("test_file2", self.scm._deleted_files())
|
| -
|
| - def test_delete_recursively(self):
|
| - self._shared_test_delete_recursively()
|
| -
|
| - def test_delete_recursively_or_not(self):
|
| - self._shared_test_delete_recursively_or_not()
|
| -
|
| - def test_move(self):
|
| - self._shared_test_move()
|
| -
|
| - def test_move_recursive(self):
|
| - self._shared_test_move_recursive()
|
| -
|
| -
|
| class GitTest(SCMTestBase):
|
| def setUp(self):
|
| super(GitTest, self).setUp()
|
| @@ -362,328 +312,6 @@ class GitTest(SCMTestBase):
|
| scm.commit_locally_with_message('message')
|
|
|
|
|
| -class GitSVNTest(SCMTestBase):
|
| - def setUp(self):
|
| - super(GitSVNTest, self).setUp()
|
| - self._set_up_svn_checkout()
|
| - self._set_up_gitsvn_checkout()
|
| - self.scm = detect_scm_system(self.git_checkout_path)
|
| - self.scm.svn_server_realm = None
|
| -
|
| - def tearDown(self):
|
| - super(GitSVNTest, self).tearDown()
|
| - self._tear_down_svn_checkout()
|
| - self._tear_down_gitsvn_checkout()
|
| -
|
| - def _set_up_gitsvn_checkout(self):
|
| - self.git_checkout_path = self._mkdtemp(suffix="git_test_checkout")
|
| - # --quiet doesn't make git svn silent
|
| - self._run_silent(['git', 'svn', 'clone', '-T', 'trunk', self.svn_repo_url, self.git_checkout_path])
|
| - self._chdir(self.git_checkout_path)
|
| - self.git_v2 = self._run(['git', '--version']).startswith('git version 2')
|
| - if self.git_v2:
|
| - # The semantics of 'git svn clone -T' changed in v2 (apparently), so the branch names are different.
|
| - # This works around it, for compatibility w/ v1.
|
| - self._run_silent(['git', 'branch', 'trunk', 'origin/trunk'])
|
| -
|
| - def _tear_down_gitsvn_checkout(self):
|
| - self._rmtree(self.git_checkout_path)
|
| -
|
| - def test_detection(self):
|
| - self.assertEqual(self.scm.display_name(), "git")
|
| - self.assertEqual(self.scm.supports_local_commits(), True)
|
| -
|
| - def test_read_git_config(self):
|
| - key = 'test.git-config'
|
| - value = 'git-config value'
|
| - self._run(['git', 'config', key, value])
|
| - self.assertEqual(self.scm.read_git_config(key), value)
|
| -
|
| - def test_local_commits(self):
|
| - test_file = self._join(self.git_checkout_path, 'test_file')
|
| - self._write_text_file(test_file, 'foo')
|
| - self._run(['git', 'commit', '-a', '-m', 'local commit'])
|
| -
|
| - self.assertEqual(len(self.scm._local_commits()), 1)
|
| -
|
| - def test_discard_local_commits(self):
|
| - test_file = self._join(self.git_checkout_path, 'test_file')
|
| - self._write_text_file(test_file, 'foo')
|
| - self._run(['git', 'commit', '-a', '-m', 'local commit'])
|
| -
|
| - self.assertEqual(len(self.scm._local_commits()), 1)
|
| - self.scm._discard_local_commits()
|
| - self.assertEqual(len(self.scm._local_commits()), 0)
|
| -
|
| - def test_delete_branch(self):
|
| - new_branch = 'foo'
|
| -
|
| - self._run(['git', 'checkout', '-b', new_branch])
|
| - self.assertEqual(self._run(['git', 'symbolic-ref', 'HEAD']).strip(), 'refs/heads/' + new_branch)
|
| -
|
| - self._run(['git', 'checkout', '-b', 'bar'])
|
| - self.scm.delete_branch(new_branch)
|
| -
|
| - self.assertNotRegexpMatches(self._run(['git', 'branch']), r'foo')
|
| -
|
| - def test_rebase_in_progress(self):
|
| - svn_test_file = self._join(self.svn_checkout_path, 'test_file')
|
| - self._write_text_file(svn_test_file, "svn_checkout")
|
| - self._run(['svn', 'commit', '--message', 'commit to conflict with git commit'], cwd=self.svn_checkout_path)
|
| -
|
| - git_test_file = self._join(self.git_checkout_path, 'test_file')
|
| - self._write_text_file(git_test_file, "git_checkout")
|
| - self._run(['git', 'commit', '-a', '-m', 'commit to be thrown away by rebase abort'])
|
| -
|
| - # Should fail due to a conflict leaving us mid-rebase.
|
| - # we use self._run_slient because --quiet doesn't actually make git svn silent.
|
| - self.assertRaises(ScriptError, self._run_silent, ['git', 'svn', '--quiet', 'rebase'])
|
| -
|
| - self.assertTrue(self.scm._rebase_in_progress())
|
| -
|
| - # Make sure our cleanup works.
|
| - self.scm._discard_working_directory_changes()
|
| - self.assertFalse(self.scm._rebase_in_progress())
|
| -
|
| - # Make sure cleanup doesn't throw when no rebase is in progress.
|
| - self.scm._discard_working_directory_changes()
|
| -
|
| - def _local_commit(self, filename, contents, message):
|
| - self._write_text_file(filename, contents)
|
| - self._run(['git', 'add', filename])
|
| - self.scm.commit_locally_with_message(message)
|
| -
|
| - def _one_local_commit(self):
|
| - self._local_commit('test_file_commit1', 'more test content', 'another test commit')
|
| -
|
| - def _one_local_commit_plus_working_copy_changes(self):
|
| - self._one_local_commit()
|
| - self._write_text_file('test_file_commit2', 'still more test content')
|
| - self._run(['git', 'add', 'test_file_commit2'])
|
| -
|
| - def _second_local_commit(self):
|
| - self._local_commit('test_file_commit2', 'still more test content', 'yet another test commit')
|
| -
|
| - def _two_local_commits(self):
|
| - self._one_local_commit()
|
| - self._second_local_commit()
|
| -
|
| - def _three_local_commits(self):
|
| - self._local_commit('test_file_commit0', 'more test content', 'another test commit')
|
| - self._two_local_commits()
|
| -
|
| - def test_locally_commit_all_working_copy_changes(self):
|
| - self._local_commit('test_file', 'test content', 'test commit')
|
| - self._write_text_file('test_file', 'changed test content')
|
| - self.assertTrue(self.scm.has_working_directory_changes())
|
| - self.scm.commit_locally_with_message('all working copy changes')
|
| - self.assertFalse(self.scm.has_working_directory_changes())
|
| -
|
| - def test_locally_commit_no_working_copy_changes(self):
|
| - self._local_commit('test_file', 'test content', 'test commit')
|
| - self._write_text_file('test_file', 'changed test content')
|
| - self.assertTrue(self.scm.has_working_directory_changes())
|
| - self.assertRaises(ScriptError, self.scm.commit_locally_with_message, 'no working copy changes', False)
|
| -
|
| - def _test_upstream_branch(self):
|
| - self._run(['git', 'checkout', '-t', '-b', 'my-branch'])
|
| - self._run(['git', 'checkout', '-t', '-b', 'my-second-branch'])
|
| - self.assertEqual(self.scm._upstream_branch(), 'my-branch')
|
| -
|
| - def test_remote_branch_ref(self):
|
| - remote_branch_ref = self.scm._remote_branch_ref()
|
| - if self.git_v2:
|
| - self.assertEqual(remote_branch_ref, 'refs/remotes/origin/trunk')
|
| - else:
|
| - self.assertEqual(remote_branch_ref, 'refs/remotes/trunk')
|
| -
|
| - def test_create_patch_local_plus_working_copy(self):
|
| - self._one_local_commit_plus_working_copy_changes()
|
| - patch = self.scm.create_patch()
|
| - self.assertRegexpMatches(patch, r'test_file_commit1')
|
| - self.assertRegexpMatches(patch, r'test_file_commit2')
|
| -
|
| - def test_create_patch(self):
|
| - self._one_local_commit_plus_working_copy_changes()
|
| - patch = self.scm.create_patch()
|
| - self.assertRegexpMatches(patch, r'test_file_commit2')
|
| - self.assertRegexpMatches(patch, r'test_file_commit1')
|
| - self.assertRegexpMatches(patch, r'Subversion Revision: 5')
|
| -
|
| - def test_create_patch_after_merge(self):
|
| - self._run(['git', 'checkout', '-b', 'dummy-branch', 'trunk~3'])
|
| - self._one_local_commit()
|
| - self._run(['git', 'merge', 'trunk'])
|
| -
|
| - patch = self.scm.create_patch()
|
| - self.assertRegexpMatches(patch, r'test_file_commit1')
|
| - self.assertRegexpMatches(patch, r'Subversion Revision: 5')
|
| -
|
| - def test_create_patch_with_changed_files(self):
|
| - self._one_local_commit_plus_working_copy_changes()
|
| - patch = self.scm.create_patch(changed_files=['test_file_commit2'])
|
| - self.assertRegexpMatches(patch, r'test_file_commit2')
|
| -
|
| - def test_create_patch_with_rm_and_changed_files(self):
|
| - self._one_local_commit_plus_working_copy_changes()
|
| - self._remove('test_file_commit1')
|
| - patch = self.scm.create_patch()
|
| - patch_with_changed_files = self.scm.create_patch(changed_files=['test_file_commit1', 'test_file_commit2'])
|
| - self.assertEqual(patch, patch_with_changed_files)
|
| -
|
| - def test_create_patch_git_commit(self):
|
| - self._two_local_commits()
|
| - patch = self.scm.create_patch(git_commit="HEAD^")
|
| - self.assertRegexpMatches(patch, r'test_file_commit1')
|
| - self.assertNotRegexpMatches(patch, r'test_file_commit2')
|
| -
|
| - def test_create_patch_git_commit_range(self):
|
| - self._three_local_commits()
|
| - patch = self.scm.create_patch(git_commit="HEAD~2..HEAD")
|
| - self.assertNotRegexpMatches(patch, r'test_file_commit0')
|
| - self.assertRegexpMatches(patch, r'test_file_commit2')
|
| - self.assertRegexpMatches(patch, r'test_file_commit1')
|
| -
|
| - def test_create_patch_working_copy_only(self):
|
| - self._one_local_commit_plus_working_copy_changes()
|
| - patch = self.scm.create_patch(git_commit="HEAD....")
|
| - self.assertNotRegexpMatches(patch, r'test_file_commit1')
|
| - self.assertRegexpMatches(patch, r'test_file_commit2')
|
| -
|
| - def test_create_patch_multiple_local_commits(self):
|
| - self._two_local_commits()
|
| - patch = self.scm.create_patch()
|
| - self.assertRegexpMatches(patch, r'test_file_commit2')
|
| - self.assertRegexpMatches(patch, r'test_file_commit1')
|
| -
|
| - def test_create_patch_not_synced(self):
|
| - self._run(['git', 'checkout', '-b', 'my-branch', 'trunk~3'])
|
| - self._two_local_commits()
|
| - patch = self.scm.create_patch()
|
| - self.assertNotRegexpMatches(patch, r'test_file2')
|
| - self.assertRegexpMatches(patch, r'test_file_commit2')
|
| - self.assertRegexpMatches(patch, r'test_file_commit1')
|
| -
|
| - def test_create_binary_patch(self):
|
| - # Create a git binary patch and check the contents.
|
| - test_file_name = 'binary_file'
|
| - test_file_path = self.fs.join(self.git_checkout_path, test_file_name)
|
| - file_contents = ''.join(map(chr, range(256)))
|
| - self._write_binary_file(test_file_path, file_contents)
|
| - self._run(['git', 'add', test_file_name])
|
| - patch = self.scm.create_patch()
|
| - self.assertRegexpMatches(patch, r'\nliteral 0\n')
|
| - self.assertRegexpMatches(patch, r'\nliteral 256\n')
|
| -
|
| - # Check if we can create a patch from a local commit.
|
| - self._write_binary_file(test_file_path, file_contents)
|
| - self._run(['git', 'add', test_file_name])
|
| - self._run(['git', 'commit', '-m', 'binary diff'])
|
| -
|
| - patch_from_local_commit = self.scm.create_patch('HEAD')
|
| - self.assertRegexpMatches(patch_from_local_commit, r'\nliteral 0\n')
|
| - self.assertRegexpMatches(patch_from_local_commit, r'\nliteral 256\n')
|
| -
|
| -
|
| - def test_changed_files_local_plus_working_copy(self):
|
| - self._one_local_commit_plus_working_copy_changes()
|
| - files = self.scm.changed_files()
|
| - self.assertIn('test_file_commit1', files)
|
| - self.assertIn('test_file_commit2', files)
|
| -
|
| - # working copy should *not* be in the list.
|
| - files = self.scm.changed_files('trunk..')
|
| - self.assertIn('test_file_commit1', files)
|
| - self.assertNotIn('test_file_commit2', files)
|
| -
|
| - # working copy *should* be in the list.
|
| - files = self.scm.changed_files('trunk....')
|
| - self.assertIn('test_file_commit1', files)
|
| - self.assertIn('test_file_commit2', files)
|
| -
|
| - def test_changed_files_git_commit(self):
|
| - self._two_local_commits()
|
| - files = self.scm.changed_files(git_commit="HEAD^")
|
| - self.assertIn('test_file_commit1', files)
|
| - self.assertNotIn('test_file_commit2', files)
|
| -
|
| - def test_changed_files_git_commit_range(self):
|
| - self._three_local_commits()
|
| - files = self.scm.changed_files(git_commit="HEAD~2..HEAD")
|
| - self.assertNotIn('test_file_commit0', files)
|
| - self.assertIn('test_file_commit1', files)
|
| - self.assertIn('test_file_commit2', files)
|
| -
|
| - def test_changed_files_working_copy_only(self):
|
| - self._one_local_commit_plus_working_copy_changes()
|
| - files = self.scm.changed_files(git_commit="HEAD....")
|
| - self.assertNotIn('test_file_commit1', files)
|
| - self.assertIn('test_file_commit2', files)
|
| -
|
| - def test_changed_files_multiple_local_commits(self):
|
| - self._two_local_commits()
|
| - files = self.scm.changed_files()
|
| - self.assertIn('test_file_commit2', files)
|
| - self.assertIn('test_file_commit1', files)
|
| -
|
| - def test_changed_files_not_synced(self):
|
| - self._run(['git', 'checkout', '-b', 'my-branch', 'trunk~3'])
|
| - self._two_local_commits()
|
| - files = self.scm.changed_files()
|
| - self.assertNotIn('test_file2', files)
|
| - self.assertIn('test_file_commit2', files)
|
| - self.assertIn('test_file_commit1', files)
|
| -
|
| - def test_changed_files_upstream(self):
|
| - self._run(['git', 'checkout', '-t', '-b', 'my-branch'])
|
| - self._one_local_commit()
|
| - self._run(['git', 'checkout', '-t', '-b', 'my-second-branch'])
|
| - self._second_local_commit()
|
| - self._write_text_file('test_file_commit0', 'more test content')
|
| - self._run(['git', 'add', 'test_file_commit0'])
|
| -
|
| - # equivalent to 'git diff my-branch..HEAD, should not include working changes
|
| - files = self.scm.changed_files(git_commit='UPSTREAM..')
|
| - self.assertNotIn('test_file_commit1', files)
|
| - self.assertIn('test_file_commit2', files)
|
| - self.assertNotIn('test_file_commit0', files)
|
| -
|
| - # equivalent to 'git diff my-branch', *should* include working changes
|
| - files = self.scm.changed_files(git_commit='UPSTREAM....')
|
| - self.assertNotIn('test_file_commit1', files)
|
| - self.assertIn('test_file_commit2', files)
|
| - self.assertIn('test_file_commit0', files)
|
| -
|
| - def test_add_recursively(self):
|
| - self._shared_test_add_recursively()
|
| -
|
| - def test_delete(self):
|
| - self._two_local_commits()
|
| - self.scm.delete('test_file_commit1')
|
| - self.assertIn("test_file_commit1", self.scm._deleted_files())
|
| -
|
| - def test_delete_list(self):
|
| - self._two_local_commits()
|
| - self.scm.delete_list(["test_file_commit1", "test_file_commit2"])
|
| - self.assertIn("test_file_commit1", self.scm._deleted_files())
|
| - self.assertIn("test_file_commit2", self.scm._deleted_files())
|
| -
|
| - def test_delete_recursively(self):
|
| - self._shared_test_delete_recursively()
|
| -
|
| - def test_delete_recursively_or_not(self):
|
| - self._shared_test_delete_recursively_or_not()
|
| -
|
| - def test_move(self):
|
| - self._shared_test_move()
|
| -
|
| - def test_move_recursive(self):
|
| - self._shared_test_move_recursive()
|
| -
|
| - def test_exists(self):
|
| - self._shared_test_exists(self.scm, self.scm.commit_locally_with_message)
|
| -
|
| -
|
| class GitTestWithMock(SCMTestBase):
|
| def make_scm(self):
|
| scm = Git(cwd=".", executive=MockExecutive(), filesystem=MockFileSystem())
|
|
|