Changeset 51005 in webkit


Ignore:
Timestamp:
Nov 15, 2009 3:32:34 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2009-11-15 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Eric Seidel.

bugzilla-tool should post git binary diff
https://bugs.webkit.org/show_bug.cgi?id=31458

Add --binary option to Git.create_patch.

  • Scripts/modules/scm.py:
  • Scripts/modules/scm_unittest.py:
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r51001 r51005  
     12009-11-15  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        bugzilla-tool should post git binary diff
     6        https://bugs.webkit.org/show_bug.cgi?id=31458
     7
     8        Add --binary option to Git.create_patch.
     9
     10        * Scripts/modules/scm.py:
     11        * Scripts/modules/scm_unittest.py:
     12
    1132009-11-15  Adam Barth  <abarth@webkit.org>
    214
  • trunk/WebKitTools/Scripts/modules/scm.py

    r51001 r51005  
    453453
    454454    def create_patch(self):
    455         return self.run_command(['git', 'diff', 'HEAD'])
     455        return self.run_command(['git', 'diff', '--binary', 'HEAD'])
    456456
    457457    @classmethod
     
    496496
    497497    def create_patch_from_local_commit(self, commit_id):
    498         return self.run_command(['git', 'diff', commit_id + "^.." + commit_id])
     498        return self.run_command(['git', 'diff', '--binary', commit_id + "^.." + commit_id])
    499499
    500500    def create_patch_since_local_commit(self, commit_id):
    501         return self.run_command(['git', 'diff', commit_id])
     501        return self.run_command(['git', 'diff', '--binary', commit_id])
    502502
    503503    def commit_locally_with_message(self, message):
  • trunk/WebKitTools/Scripts/modules/scm_unittest.py

    r50863 r51005  
    561561        self._shared_test_svn_apply_git_patch()
    562562
     563    def test_create_binary_patch(self):
     564        # Create a git binary patch and check the contents.
     565        scm = detect_scm_system(self.git_checkout_path)
     566        test_file_path = os.path.join(self.git_checkout_path, 'binary_file')
     567        file_contents = ''.join(map(chr, range(256)))
     568        write_into_file_at_path(test_file_path, file_contents)
     569        run(['git', 'add', test_file_path])
     570        patch = scm.create_patch()
     571        self.assertTrue(re.search(r'\nliteral 0\n', patch))
     572        self.assertTrue(re.search(r'\nliteral 256\n', patch))
     573
     574        # Check if we can apply the created patch.
     575        run(['git', 'rm', '-f', test_file_path])
     576        self._setup_webkittools_scripts_symlink(scm)
     577        self.scm.apply_patch(self._create_patch(patch))
     578        self.assertEqual(file_contents, read_from_path(test_file_path))
     579
     580        # Check if we can create a patch from a local commit.
     581        write_into_file_at_path(test_file_path, file_contents)
     582        run(['git', 'add', test_file_path])
     583        run(['git', 'commit', '-m', 'binary diff'])
     584        patch_from_local_commit = scm.create_patch_from_local_commit('HEAD')
     585        self.assertTrue(re.search(r'\nliteral 0\n', patch_from_local_commit))
     586        self.assertTrue(re.search(r'\nliteral 256\n', patch_from_local_commit))
     587        patch_since_local_commit = scm.create_patch_since_local_commit('HEAD^1')
     588        self.assertTrue(re.search(r'\nliteral 0\n', patch_since_local_commit))
     589        self.assertTrue(re.search(r'\nliteral 256\n', patch_since_local_commit))
     590        self.assertEqual(patch_from_local_commit, patch_since_local_commit)
     591
     592
    563593if __name__ == '__main__':
    564594    unittest.main()
Note: See TracChangeset for help on using the changeset viewer.