Changeset 56600 in webkit
- Timestamp:
- Mar 25, 2010 10:32:12 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r56599 r56600 1 2010-03-25 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Move apply_patch from scm to checkout 6 https://bugs.webkit.org/show_bug.cgi?id=36635 7 8 SCM shouldn't have any knowledge of WebKit scripts. 9 10 * Scripts/webkitpy/common/checkout/api.py: 11 * Scripts/webkitpy/common/checkout/scm.py: 12 * Scripts/webkitpy/common/checkout/scm_unittest.py: 13 * Scripts/webkitpy/tool/mocktool.py: 14 * Scripts/webkitpy/tool/steps/applypatch.py: 15 1 16 2010-03-25 Eric Seidel <eric@webkit.org> 2 17 -
trunk/WebKitTools/Scripts/webkitpy/common/checkout/api.py
r56599 r56600 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 import subprocess 30 29 31 from webkitpy.common.checkout.commitinfo import CommitInfo 30 32 from webkitpy.common.checkout.changelog import ChangeLog 31 33 from webkitpy.common.checkout.scm import CommitMessage 32 from webkitpy.common.system.executive import ScriptError34 from webkitpy.common.system.executive import Executive, run_command, ScriptError 33 35 from webkitpy.common.system.deprecated_logging import log 34 36 … … 65 67 # FIXME: We should sort and label the ChangeLog messages like commit-log-editor does. 66 68 return CommitMessage("".join(changelog_messages).splitlines()) 69 70 def apply_patch(self, patch, force=False): 71 # It's possible that the patch was not made from the root directory. 72 # We should detect and handle that case. 73 # FIXME: Use Executive instead of subprocess here. 74 curl_process = subprocess.Popen(['curl', '--location', '--silent', '--show-error', patch.url()], stdout=subprocess.PIPE) 75 # FIXME: Move _scm.script_path here once we get rid of all the dependencies. 76 args = [self._scm.script_path('svn-apply')] 77 if patch.reviewer(): 78 args += ['--reviewer', patch.reviewer().full_name] 79 if force: 80 args.append('--force') 81 82 run_command(args, input=curl_process.stdout) -
trunk/WebKitTools/Scripts/webkitpy/common/checkout/scm.py
r56592 r56600 32 32 import os 33 33 import re 34 import subprocess35 34 36 35 from webkitpy.common.checkout.changelog import ChangeLog, is_path_to_changelog … … 120 119 error("Working directory has local commits, pass --force-clean to continue.") 121 120 self.discard_local_commits() 122 123 def apply_patch(self, patch, force=False):124 # It's possible that the patch was not made from the root directory.125 # We should detect and handle that case.126 # FIXME: scm.py should not deal with fetching Attachment data. Attachment should just have a .data() accessor.127 curl_process = subprocess.Popen(['curl', '--location', '--silent', '--show-error', patch.url()], stdout=subprocess.PIPE)128 args = [self.script_path('svn-apply')]129 if patch.reviewer():130 args += ['--reviewer', patch.reviewer().full_name]131 if force:132 args.append('--force')133 134 run_command(args, input=curl_process.stdout)135 121 136 122 def run_status_and_extract_filenames(self, status_command, status_regexp): -
trunk/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py
r56517 r56600 40 40 41 41 from datetime import date 42 from webkitpy.common.checkout.api import Checkout 42 43 from webkitpy.common.checkout.scm import detect_scm_system, SCM, SVN, CheckoutNeedsUpdate, commit_error_handler 43 44 from webkitpy.common.net.bugzilla import Attachment # FIXME: This should not be needed … … 255 256 256 257 """ 257 self. scm.apply_patch(self._create_patch(git_binary_addition))258 self.checkout.apply_patch(self._create_patch(git_binary_addition)) 258 259 added = read_from_path('fizzbuzz7.gif') 259 260 self.assertEqual(512, len(added)) … … 262 263 263 264 # The file already exists. 264 self.assertRaises(ScriptError, self. scm.apply_patch, self._create_patch(git_binary_addition))265 self.assertRaises(ScriptError, self.checkout.apply_patch, self._create_patch(git_binary_addition)) 265 266 266 267 git_binary_modification = """diff --git a/fizzbuzz7.gif b/fizzbuzz7.gif … … 283 284 284 285 """ 285 self. scm.apply_patch(self._create_patch(git_binary_modification))286 self.checkout.apply_patch(self._create_patch(git_binary_modification)) 286 287 modified = read_from_path('fizzbuzz7.gif') 287 288 self.assertEqual('foobar\n', modified) … … 289 290 290 291 # Applying the same modification should fail. 291 self.assertRaises(ScriptError, self. scm.apply_patch, self._create_patch(git_binary_modification))292 self.assertRaises(ScriptError, self.checkout.apply_patch, self._create_patch(git_binary_modification)) 292 293 293 294 git_binary_deletion = """diff --git a/fizzbuzz7.gif b/fizzbuzz7.gif … … 302 303 303 304 """ 304 self. scm.apply_patch(self._create_patch(git_binary_deletion))305 self.checkout.apply_patch(self._create_patch(git_binary_deletion)) 305 306 self.assertFalse(os.path.exists('fizzbuzz7.gif')) 306 307 self.assertFalse('fizzbuzz7.gif' in self.scm.changed_files()) 307 308 308 309 # Cannot delete again. 309 self.assertRaises(ScriptError, self. scm.apply_patch, self._create_patch(git_binary_deletion))310 self.assertRaises(ScriptError, self.checkout.apply_patch, self._create_patch(git_binary_deletion)) 310 311 311 312 … … 402 403 403 404 self._setup_webkittools_scripts_symlink(self.scm) 404 self. scm.apply_patch(self._create_patch(one_line_overlap_patch))405 self.checkout.apply_patch(self._create_patch(one_line_overlap_patch)) 405 406 expected_changelog_contents = "%s\n%s" % (self._set_date_and_reviewer(one_line_overlap_entry), changelog_contents) 406 407 self.assertEquals(read_from_path('ChangeLog'), expected_changelog_contents) 407 408 408 409 self.scm.revert_files(['ChangeLog']) 409 self. scm.apply_patch(self._create_patch(two_line_overlap_patch))410 self.checkout.apply_patch(self._create_patch(two_line_overlap_patch)) 410 411 expected_changelog_contents = "%s\n%s" % (self._set_date_and_reviewer(two_line_overlap_entry), changelog_contents) 411 412 self.assertEquals(read_from_path('ChangeLog'), expected_changelog_contents) … … 415 416 os.chdir(self.svn_checkout_path) 416 417 self.scm = detect_scm_system(self.svn_checkout_path) 418 # For historical reasons, we test some checkout code here too. 419 self.checkout = Checkout(self.scm) 417 420 418 421 def tearDown(self): … … 463 466 self._setup_webkittools_scripts_symlink(self.scm) 464 467 patch_file = self._create_patch(patch_contents) 465 self. scm.apply_patch(patch_file)468 self.checkout.apply_patch(patch_file) 466 469 actual_contents = read_from_path("test_file.swf") 467 470 self.assertEqual(actual_contents, expected_contents) … … 471 474 patch = self._create_patch(run_command(['svn', 'diff', '-r4:3'])) 472 475 self._setup_webkittools_scripts_symlink(scm) 473 scm.apply_patch(patch)476 Checkout(scm).apply_patch(patch) 474 477 475 478 def test_apply_svn_patch_force(self): … … 477 480 patch = self._create_patch(run_command(['svn', 'diff', '-r2:4'])) 478 481 self._setup_webkittools_scripts_symlink(scm) 479 self.assertRaises(ScriptError, scm.apply_patch, patch, force=True)482 self.assertRaises(ScriptError, Checkout(scm).apply_patch, patch, force=True) 480 483 481 484 def test_commit_logs(self): … … 545 548 os.chdir(self.git_checkout_path) 546 549 self.scm = detect_scm_system(self.git_checkout_path) 550 # For historical reasons, we test some checkout code here too. 551 self.checkout = Checkout(self.scm) 547 552 548 553 def tearDown(self): … … 602 607 patch = self._create_patch(run_command(['git', 'diff', 'HEAD..HEAD^'])) 603 608 self._setup_webkittools_scripts_symlink(scm) 604 scm.apply_patch(patch)609 Checkout(scm).apply_patch(patch) 605 610 606 611 def test_apply_git_patch_force(self): … … 608 613 patch = self._create_patch(run_command(['git', 'diff', 'HEAD~2..HEAD'])) 609 614 self._setup_webkittools_scripts_symlink(scm) 610 self.assertRaises(ScriptError, scm.apply_patch, patch, force=True)615 self.assertRaises(ScriptError, Checkout(scm).apply_patch, patch, force=True) 611 616 612 617 def test_commit_text_parsing(self): … … 637 642 run_command(['git', 'rm', '-f', test_file_name]) 638 643 self._setup_webkittools_scripts_symlink(scm) 639 self. scm.apply_patch(self._create_patch(patch))644 self.checkout.apply_patch(self._create_patch(patch)) 640 645 self.assertEqual(file_contents, read_from_path(test_file_path)) 641 646 -
trunk/WebKitTools/Scripts/webkitpy/tool/mocktool.py
r56592 r56600 382 382 return Mock() 383 383 384 def apply_patch(self, patch, force=False): 385 pass 386 384 387 385 388 class MockUser(object): -
trunk/WebKitTools/Scripts/webkitpy/tool/steps/applypatch.py
r56544 r56600 40 40 def run(self, state): 41 41 log("Processing patch %s from bug %s." % (state["patch"].id(), state["patch"].bug_id())) 42 self._tool. scm().apply_patch(state["patch"], force=self._options.non_interactive)42 self._tool.checkout().apply_patch(state["patch"], force=self._options.non_interactive)
Note: See TracChangeset
for help on using the changeset viewer.