Changeset 56600 in webkit


Ignore:
Timestamp:
Mar 25, 2010 10:32:12 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-03-25 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Move apply_patch from scm to checkout
https://bugs.webkit.org/show_bug.cgi?id=36635

SCM shouldn't have any knowledge of WebKit scripts.

  • Scripts/webkitpy/common/checkout/api.py:
  • Scripts/webkitpy/common/checkout/scm.py:
  • Scripts/webkitpy/common/checkout/scm_unittest.py:
  • Scripts/webkitpy/tool/mocktool.py:
  • Scripts/webkitpy/tool/steps/applypatch.py:
Location:
trunk/WebKitTools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r56599 r56600  
     12010-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
    1162010-03-25  Eric Seidel  <eric@webkit.org>
    217
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/api.py

    r56599 r56600  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
     29import subprocess
     30
    2931from webkitpy.common.checkout.commitinfo import CommitInfo
    3032from webkitpy.common.checkout.changelog import ChangeLog
    3133from webkitpy.common.checkout.scm import CommitMessage
    32 from webkitpy.common.system.executive import ScriptError
     34from webkitpy.common.system.executive import Executive, run_command, ScriptError
    3335from webkitpy.common.system.deprecated_logging import log
    3436
     
    6567        # FIXME: We should sort and label the ChangeLog messages like commit-log-editor does.
    6668        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  
    3232import os
    3333import re
    34 import subprocess
    3534
    3635from webkitpy.common.checkout.changelog import ChangeLog, is_path_to_changelog
     
    120119            error("Working directory has local commits, pass --force-clean to continue.")
    121120        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)
    135121
    136122    def run_status_and_extract_filenames(self, status_command, status_regexp):
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py

    r56517 r56600  
    4040
    4141from datetime import date
     42from webkitpy.common.checkout.api import Checkout
    4243from webkitpy.common.checkout.scm import detect_scm_system, SCM, SVN, CheckoutNeedsUpdate, commit_error_handler
    4344from webkitpy.common.net.bugzilla import Attachment # FIXME: This should not be needed
     
    255256
    256257"""
    257         self.scm.apply_patch(self._create_patch(git_binary_addition))
     258        self.checkout.apply_patch(self._create_patch(git_binary_addition))
    258259        added = read_from_path('fizzbuzz7.gif')
    259260        self.assertEqual(512, len(added))
     
    262263
    263264        # 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))
    265266
    266267        git_binary_modification = """diff --git a/fizzbuzz7.gif b/fizzbuzz7.gif
     
    283284
    284285"""
    285         self.scm.apply_patch(self._create_patch(git_binary_modification))
     286        self.checkout.apply_patch(self._create_patch(git_binary_modification))
    286287        modified = read_from_path('fizzbuzz7.gif')
    287288        self.assertEqual('foobar\n', modified)
     
    289290
    290291        # 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))
    292293
    293294        git_binary_deletion = """diff --git a/fizzbuzz7.gif b/fizzbuzz7.gif
     
    302303
    303304"""
    304         self.scm.apply_patch(self._create_patch(git_binary_deletion))
     305        self.checkout.apply_patch(self._create_patch(git_binary_deletion))
    305306        self.assertFalse(os.path.exists('fizzbuzz7.gif'))
    306307        self.assertFalse('fizzbuzz7.gif' in self.scm.changed_files())
    307308
    308309        # 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))
    310311
    311312
     
    402403
    403404        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))
    405406        expected_changelog_contents = "%s\n%s" % (self._set_date_and_reviewer(one_line_overlap_entry), changelog_contents)
    406407        self.assertEquals(read_from_path('ChangeLog'), expected_changelog_contents)
    407408
    408409        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))
    410411        expected_changelog_contents = "%s\n%s" % (self._set_date_and_reviewer(two_line_overlap_entry), changelog_contents)
    411412        self.assertEquals(read_from_path('ChangeLog'), expected_changelog_contents)
     
    415416        os.chdir(self.svn_checkout_path)
    416417        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)
    417420
    418421    def tearDown(self):
     
    463466        self._setup_webkittools_scripts_symlink(self.scm)
    464467        patch_file = self._create_patch(patch_contents)
    465         self.scm.apply_patch(patch_file)
     468        self.checkout.apply_patch(patch_file)
    466469        actual_contents = read_from_path("test_file.swf")
    467470        self.assertEqual(actual_contents, expected_contents)
     
    471474        patch = self._create_patch(run_command(['svn', 'diff', '-r4:3']))
    472475        self._setup_webkittools_scripts_symlink(scm)
    473         scm.apply_patch(patch)
     476        Checkout(scm).apply_patch(patch)
    474477
    475478    def test_apply_svn_patch_force(self):
     
    477480        patch = self._create_patch(run_command(['svn', 'diff', '-r2:4']))
    478481        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)
    480483
    481484    def test_commit_logs(self):
     
    545548        os.chdir(self.git_checkout_path)
    546549        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)
    547552
    548553    def tearDown(self):
     
    602607        patch = self._create_patch(run_command(['git', 'diff', 'HEAD..HEAD^']))
    603608        self._setup_webkittools_scripts_symlink(scm)
    604         scm.apply_patch(patch)
     609        Checkout(scm).apply_patch(patch)
    605610
    606611    def test_apply_git_patch_force(self):
     
    608613        patch = self._create_patch(run_command(['git', 'diff', 'HEAD~2..HEAD']))
    609614        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)
    611616
    612617    def test_commit_text_parsing(self):
     
    637642        run_command(['git', 'rm', '-f', test_file_name])
    638643        self._setup_webkittools_scripts_symlink(scm)
    639         self.scm.apply_patch(self._create_patch(patch))
     644        self.checkout.apply_patch(self._create_patch(patch))
    640645        self.assertEqual(file_contents, read_from_path(test_file_path))
    641646
  • trunk/WebKitTools/Scripts/webkitpy/tool/mocktool.py

    r56592 r56600  
    382382        return Mock()
    383383
     384    def apply_patch(self, patch, force=False):
     385        pass
     386
    384387
    385388class MockUser(object):
  • trunk/WebKitTools/Scripts/webkitpy/tool/steps/applypatch.py

    r56544 r56600  
    4040    def run(self, state):
    4141        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.