2010-12-02 Ojan Vafai <ojan@chromium.org>
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Dec 2010 20:00:21 +0000 (20:00 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Dec 2010 20:00:21 +0000 (20:00 +0000)
        Reviewed by Eric Seidel.

        make webkit-patch command work when the git branch is not synced to the remote svn branch
        https://bugs.webkit.org/show_bug.cgi?id=50424

        * Scripts/webkitpy/common/checkout/scm.py:
        * Scripts/webkitpy/common/checkout/scm_unittest.py:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@73384 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKitTools/ChangeLog
WebKitTools/Scripts/webkitpy/common/checkout/scm.py
WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py

index c3d03181724233c4b7fec7e868a4864de2563efa..f9778e55de655127cab8d7182a72fd631dd1fc45 100644 (file)
@@ -1,3 +1,13 @@
+2010-12-02  Ojan Vafai  <ojan@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        make webkit-patch command work when the git branch is not synced to the remote svn branch
+        https://bugs.webkit.org/show_bug.cgi?id=50424
+
+        * Scripts/webkitpy/common/checkout/scm.py:
+        * Scripts/webkitpy/common/checkout/scm_unittest.py:
+
 2010-12-06  Patrick Gansterer  <paroga@webkit.org>
 
         Reviewed by Andreas Kling.
index d39b8b47cc5454bbb7cac703db258ffb83f5621f..ee2bb412ba055cabd2221c6f15bb63f89b27a01f 100644 (file)
@@ -642,10 +642,6 @@ class Git(SCM):
     def delete(self, path):
         return self.run(["git", "rm", "-f", path])
 
-    def _assert_synced(self):
-        if len(run_command(['git', 'rev-list', '--max-count=1', self.remote_branch_ref(), '^HEAD'])):
-            raise ScriptError(message="Not fully merged/rebased to %s. This branch needs to be synced first." % self.remote_branch_ref())
-
     def merge_base(self, git_commit):
         if git_commit:
             # Special-case HEAD.. to mean working-copy changes only.
@@ -656,7 +652,6 @@ class Git(SCM):
                 git_commit = git_commit + "^.." + git_commit
             return git_commit
 
-        self._assert_synced()
         return self.remote_merge_base()
 
     def changed_files(self, git_commit=None):
@@ -788,8 +783,7 @@ class Git(SCM):
 
         if not force_squash:
             self._assert_can_squash(working_directory_is_clean)
-        self._assert_synced()
-        self.run(['git', 'reset', '--soft', self.remote_branch_ref()])
+        self.run(['git', 'reset', '--soft', self.remote_merge_base()])
         self.commit_locally_with_message(message)
         return self.push_local_commits_to_server()
 
index 46a2acf3cd35f208eebd841b2eedac36a226303f..55cfce3255c6ca7feea8232a7c5773d04e4a36d9 100644 (file)
@@ -962,10 +962,13 @@ class GitSVNTest(SCMTest):
         svn_log = run_command(['git', 'svn', 'log', '--limit=1', '--verbose'])
         self.assertTrue(re.search(r'test_file_commit1', svn_log))
 
+    def _local_commit(self, filename, contents, message):
+        write_into_file_at_path(filename, contents)
+        run_command(['git', 'add', filename])
+        self.scm.commit_locally_with_message(message)
+
     def _one_local_commit(self):
-        write_into_file_at_path('test_file_commit1', 'more test content')
-        run_command(['git', 'add', 'test_file_commit1'])
-        self.scm.commit_locally_with_message("another test commit")
+        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()
@@ -974,14 +977,10 @@ class GitSVNTest(SCMTest):
 
     def _two_local_commits(self):
         self._one_local_commit()
-        write_into_file_at_path('test_file_commit2', 'still more test content')
-        run_command(['git', 'add', 'test_file_commit2'])
-        self.scm.commit_locally_with_message("yet another test commit")
+        self._local_commit('test_file_commit2', 'still more test content', 'yet another test commit')
 
     def _three_local_commits(self):
-        write_into_file_at_path('test_file_commit0', 'more test content')
-        run_command(['git', 'add', 'test_file_commit0'])
-        self.scm.commit_locally_with_message("another test commit")
+        self._local_commit('test_file_commit0', 'more test content', 'another test commit')
         self._two_local_commits()
 
     def test_revisions_changing_files_with_local_commit(self):
@@ -1083,6 +1082,21 @@ class GitSVNTest(SCMTest):
         self._two_local_commits()
         scm = detect_scm_system(self.git_checkout_path)
         self.assertRaises(AmbiguousCommitError, scm.commit_with_message, "another test commit")
+        commit_text = scm.commit_with_message("another test commit", force_squash=True)
+
+        self.assertEqual(scm.svn_revision_from_commit_text(commit_text), '6')
+
+        svn_log = run_command(['git', 'svn', 'log', '--limit=1', '--verbose'])
+        self.assertFalse(re.search(r'test_file2', svn_log))
+        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_with_conflict(self):
+        run_command(['git', 'checkout', '-b', 'my-branch', 'trunk~3'])
+        self._local_commit('test_file2', 'asdf', 'asdf commit')
+
+        scm = detect_scm_system(self.git_checkout_path)
+        # There's a conflict between trunk and the test_file2 modification.
         self.assertRaises(ScriptError, scm.commit_with_message, "another test commit", force_squash=True)
 
     def test_remote_branch_ref(self):
@@ -1158,7 +1172,10 @@ class GitSVNTest(SCMTest):
         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)
+        patch = scm.create_patch()
+        self.assertFalse(re.search(r'test_file2', patch))
+        self.assertTrue(re.search(r'test_file_commit2', patch))
+        self.assertTrue(re.search(r'test_file_commit1', patch))
 
     def test_create_binary_patch(self):
         # Create a git binary patch and check the contents.
@@ -1226,7 +1243,19 @@ class GitSVNTest(SCMTest):
         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)
+        files = scm.changed_files()
+        self.assertFalse('test_file2' in files)
+        self.assertTrue('test_file_commit2' in files)
+        self.assertTrue('test_file_commit1' in files)
+
+    def test_changed_files_not_synced(self):
+        run_command(['git', 'checkout', '-b', 'my-branch', 'trunk~3'])
+        self._two_local_commits()
+        scm = detect_scm_system(self.git_checkout_path)
+        files = scm.changed_files()
+        self.assertFalse('test_file2' in files)
+        self.assertTrue('test_file_commit2' in files)
+        self.assertTrue('test_file_commit1' in files)
 
     def test_changed_files(self):
         self._shared_test_changed_files()