Changeset 55131 in webkit


Ignore:
Timestamp:
Feb 23, 2010 1:31:04 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-02-23 Daniel Bates <dbates@rim.com>

Reviewed by Eric Seidel.

https://bugs.webkit.org/show_bug.cgi?id=34439

Prompts a person for their SVN username if not already cached (by Subversion).

Currently, webkit-patch is unable to commit to the SVN repo. unless the
WebKit SVN username is already cached (from of a prior commit by hand)
because "svn commit" (called by webkit-patch) defaults to using the system
login name unless the username is already cached or specified on the
command line.

  • Scripts/webkitpy/scm.py: Added methods SVN.has_authorization_for_realm and modified SVN.commit_with_message to call it. Added optional username parameter to method SVN.commit_with_message.
  • Scripts/webkitpy/scm_unittest.py: Added unit test methods: SVNTest.test_commit_with_username, SVNTest.test_has_authorization_for_realm, and SVNTest.test_not_have_authorization_for_realm.
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r55123 r55131  
     12010-02-23  Daniel Bates  <dbates@rim.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=34439
     6
     7        Prompts a person for their SVN username if not already cached (by Subversion).
     8
     9        Currently, webkit-patch is unable to commit to the SVN repo. unless the
     10        WebKit SVN username is already cached (from of a prior commit by hand)
     11        because "svn commit" (called by webkit-patch) defaults to using the system
     12        login name unless the username is already cached or specified on the
     13        command line.
     14
     15        * Scripts/webkitpy/scm.py: Added methods SVN.has_authorization_for_realm and
     16        modified SVN.commit_with_message to call it. Added optional username parameter
     17        to method SVN.commit_with_message.
     18        * Scripts/webkitpy/scm_unittest.py: Added unit test methods: SVNTest.test_commit_with_username,
     19        SVNTest.test_has_authorization_for_realm, and SVNTest.test_not_have_authorization_for_realm.
     20
    1212010-02-22  Dirk Pranke  <dpranke@chromium.org>
    222
  • trunk/WebKitTools/Scripts/webkitpy/scm.py

    r53609 r55131  
    3737from webkitpy.changelogs import ChangeLog
    3838from webkitpy.executive import Executive, run_command, ScriptError
     39from webkitpy.user import User
    3940from webkitpy.webkit_logging import error, log
    4041
     
    257258
    258259class SVN(SCM):
     260    # FIXME: We should move these values to a WebKit-specific config. file.
     261    svn_server_host = "svn.webkit.org"
     262    svn_server_realm = "<http://svn.webkit.org:80> Mac OS Forge"
     263
    259264    def __init__(self, cwd, dryrun=False):
    260265        SCM.__init__(self, cwd, dryrun)
     
    300305        return "^Committed revision (?P<svn_revision>\d+)\.$"
    301306
     307    def has_authorization_for_realm(self, realm=svn_server_realm, home_directory=os.getenv("HOME")):
     308        # Assumes find and grep are installed.
     309        if not os.path.isdir(os.path.join(home_directory, ".subversion")):
     310            return False
     311        find_args = ["find", ".subversion", "-type", "f", "-exec", "grep", "-q", realm, "{}", ";", "-print"];
     312        find_output = run_command(find_args, cwd=home_directory, error_handler=Executive.ignore_error).rstrip()
     313        return find_output and os.path.isfile(os.path.join(home_directory, find_output))
     314
    302315    def svn_version(self):
    303316        if not self.cached_version:
     
    348361        run_command(['svn', 'revert'] + file_paths)
    349362
    350     def commit_with_message(self, message):
     363    def commit_with_message(self, message, username):
    351364        if self.dryrun:
    352365            # Return a string which looks like a commit so that things which parse this output will succeed.
    353366            return "Dry run, no commit.\nCommitted revision 0."
    354         return run_command(['svn', 'commit', '-m', message], error_handler=commit_error_handler)
     367        svn_commit_args = ["svn", "commit"]
     368        if not username and not self.has_authorization_for_realm():
     369            username = User.prompt("%s login: " % self.svn_server_host, repeat=5)
     370            if not username:
     371                raise Exception("You need to specify the username on %s to perform the commit as." % self.svn_server_host)
     372        if username:
     373            svn_commit_args.extend(["--username", username])
     374        svn_commit_args.extend(["-m", message])
     375        return run_command(svn_commit_args, error_handler=commit_error_handler)
    355376
    356377    def svn_commit_log(self, svn_revision):
  • trunk/WebKitTools/Scripts/webkitpy/scm_unittest.py

    r53609 r55131  
    4040from datetime import date
    4141from webkitpy.executive import Executive, run_command, ScriptError
    42 from webkitpy.scm import detect_scm_system, SCM, CheckoutNeedsUpdate, commit_error_handler
     42from webkitpy.scm import detect_scm_system, SCM, SVN, CheckoutNeedsUpdate, commit_error_handler
    4343from webkitpy.bugzilla import Attachment # FIXME: This should not be needed
    4444
     
    181181    # Tests which both GitTest and SVNTest should run.
    182182    # FIXME: There must be a simpler way to add these w/o adding a wrapper method to both subclasses
    183     def _shared_test_commit_with_message(self):
     183    def _shared_test_commit_with_message(self, username):
    184184        write_into_file_at_path('test_file', 'more test content')
    185         commit_text = self.scm.commit_with_message('another test commit')
     185        commit_text = self.scm.commit_with_message("another test commit", username)
    186186        self.assertEqual(self.scm.svn_revision_from_commit_text(commit_text), '5')
    187187
    188188        self.scm.dryrun = True
    189189        write_into_file_at_path('test_file', 'still more test content')
    190         commit_text = self.scm.commit_with_message('yet another test commit')
     190        commit_text = self.scm.commit_with_message("yet another test commit", username)
    191191        self.assertEqual(self.scm.svn_revision_from_commit_text(commit_text), '0')
    192192
     
    460460        self._shared_test_commit_with_message()
    461461
     462    def test_commit_with_username(self):
     463        self._shared_test_commit_with_message("dbates@webkit.org")
     464
     465    def test_has_authorization_for_realm(self):
     466        scm = detect_scm_system(self.svn_checkout_path)
     467        fake_home_dir = tempfile.mkdtemp(suffix="fake_home_dir")
     468        svn_config_dir_path = os.path.join(fake_home_dir, ".subversion")
     469        os.mkdir(svn_config_dir_path)
     470        fake_webkit_auth_file = os.path.join(svn_config_dir_path, "fake_webkit_auth_file")
     471        write_into_file_at_path(fake_webkit_auth_file, SVN.svn_server_realm)
     472        self.assertTrue(scm.has_authorization_for_realm(home_directory=fake_home_dir))
     473        os.remove(fake_webkit_auth_file)
     474        os.rmdir(svn_config_dir_path)
     475        os.rmdir(fake_home_dir)
     476
     477    def test_not_have_authorization_for_realm(self):
     478        scm = detect_scm_system(self.svn_checkout_path)
     479        fake_home_dir = tempfile.mkdtemp(suffix="fake_home_dir")
     480        svn_config_dir_path = os.path.join(fake_home_dir, ".subversion")
     481        os.mkdir(svn_config_dir_path)
     482        self.assertFalse(scm.has_authorization_for_realm(home_directory=fake_home_dir))
     483        os.rmdir(svn_config_dir_path)
     484        os.rmdir(fake_home_dir)
     485
    462486    def test_reverse_diff(self):
    463487        self._shared_test_reverse_diff()
Note: See TracChangeset for help on using the changeset viewer.