[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Thu Apr 8 01:56:28 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 2273198a2ac94cf8337e16a3ce8d6d50f15990b8
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Feb 23 09:31:04 2010 +0000

    2010-02-23  Daniel Bates  <dbates at 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.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55131 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 31d1ca7..43830ff 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,23 @@
+2010-02-23  Daniel Bates  <dbates at 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.
+
 2010-02-22  Dirk Pranke  <dpranke at chromium.org>
 
         Reviewed by Eric Siedel.
diff --git a/WebKitTools/Scripts/webkitpy/scm.py b/WebKitTools/Scripts/webkitpy/scm.py
index 743f3fe..bac06d8 100644
--- a/WebKitTools/Scripts/webkitpy/scm.py
+++ b/WebKitTools/Scripts/webkitpy/scm.py
@@ -36,6 +36,7 @@ import subprocess
 # Import WebKit-specific modules.
 from webkitpy.changelogs import ChangeLog
 from webkitpy.executive import Executive, run_command, ScriptError
+from webkitpy.user import User
 from webkitpy.webkit_logging import error, log
 
 def detect_scm_system(path):
@@ -256,6 +257,10 @@ class SCM:
 
 
 class SVN(SCM):
+    # FIXME: We should move these values to a WebKit-specific config. file.
+    svn_server_host = "svn.webkit.org"
+    svn_server_realm = "<http://svn.webkit.org:80> Mac OS Forge"
+
     def __init__(self, cwd, dryrun=False):
         SCM.__init__(self, cwd, dryrun)
         self.cached_version = None
@@ -299,6 +304,14 @@ class SVN(SCM):
     def commit_success_regexp():
         return "^Committed revision (?P<svn_revision>\d+)\.$"
 
+    def has_authorization_for_realm(self, realm=svn_server_realm, home_directory=os.getenv("HOME")):
+        # Assumes find and grep are installed.
+        if not os.path.isdir(os.path.join(home_directory, ".subversion")):
+            return False
+        find_args = ["find", ".subversion", "-type", "f", "-exec", "grep", "-q", realm, "{}", ";", "-print"];
+        find_output = run_command(find_args, cwd=home_directory, error_handler=Executive.ignore_error).rstrip()
+        return find_output and os.path.isfile(os.path.join(home_directory, find_output))
+
     def svn_version(self):
         if not self.cached_version:
             self.cached_version = run_command(['svn', '--version', '--quiet'])
@@ -347,11 +360,19 @@ class SVN(SCM):
     def revert_files(self, file_paths):
         run_command(['svn', 'revert'] + file_paths)
 
-    def commit_with_message(self, message):
+    def commit_with_message(self, message, username):
         if self.dryrun:
             # Return a string which looks like a commit so that things which parse this output will succeed.
             return "Dry run, no commit.\nCommitted revision 0."
-        return run_command(['svn', 'commit', '-m', message], error_handler=commit_error_handler)
+        svn_commit_args = ["svn", "commit"]
+        if not username and not self.has_authorization_for_realm():
+            username = User.prompt("%s login: " % self.svn_server_host, repeat=5)
+            if not username:
+                raise Exception("You need to specify the username on %s to perform the commit as." % self.svn_server_host)
+        if username:
+            svn_commit_args.extend(["--username", username])
+        svn_commit_args.extend(["-m", message])
+        return run_command(svn_commit_args, error_handler=commit_error_handler)
 
     def svn_commit_log(self, svn_revision):
         svn_revision = self.strip_r_from_svn_revision(str(svn_revision))
diff --git a/WebKitTools/Scripts/webkitpy/scm_unittest.py b/WebKitTools/Scripts/webkitpy/scm_unittest.py
index 73faf40..dd76346 100644
--- a/WebKitTools/Scripts/webkitpy/scm_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/scm_unittest.py
@@ -39,7 +39,7 @@ import urllib
 
 from datetime import date
 from webkitpy.executive import Executive, run_command, ScriptError
-from webkitpy.scm import detect_scm_system, SCM, CheckoutNeedsUpdate, commit_error_handler
+from webkitpy.scm import detect_scm_system, SCM, SVN, CheckoutNeedsUpdate, commit_error_handler
 from webkitpy.bugzilla import Attachment # FIXME: This should not be needed
 
 # Eventually we will want to write tests which work for both scms. (like update_webkit, changed_files, etc.)
@@ -180,14 +180,14 @@ class SCMTest(unittest.TestCase):
 
     # Tests which both GitTest and SVNTest should run.
     # FIXME: There must be a simpler way to add these w/o adding a wrapper method to both subclasses
-    def _shared_test_commit_with_message(self):
+    def _shared_test_commit_with_message(self, username):
         write_into_file_at_path('test_file', 'more test content')
-        commit_text = self.scm.commit_with_message('another test commit')
+        commit_text = self.scm.commit_with_message("another test commit", username)
         self.assertEqual(self.scm.svn_revision_from_commit_text(commit_text), '5')
 
         self.scm.dryrun = True
         write_into_file_at_path('test_file', 'still more test content')
-        commit_text = self.scm.commit_with_message('yet another test commit')
+        commit_text = self.scm.commit_with_message("yet another test commit", username)
         self.assertEqual(self.scm.svn_revision_from_commit_text(commit_text), '0')
 
     def _shared_test_reverse_diff(self):
@@ -459,6 +459,30 @@ Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
     def test_commit_text_parsing(self):
         self._shared_test_commit_with_message()
 
+    def test_commit_with_username(self):
+        self._shared_test_commit_with_message("dbates at webkit.org")
+
+    def test_has_authorization_for_realm(self):
+        scm = detect_scm_system(self.svn_checkout_path)
+        fake_home_dir = tempfile.mkdtemp(suffix="fake_home_dir")
+        svn_config_dir_path = os.path.join(fake_home_dir, ".subversion")
+        os.mkdir(svn_config_dir_path)
+        fake_webkit_auth_file = os.path.join(svn_config_dir_path, "fake_webkit_auth_file")
+        write_into_file_at_path(fake_webkit_auth_file, SVN.svn_server_realm)
+        self.assertTrue(scm.has_authorization_for_realm(home_directory=fake_home_dir))
+        os.remove(fake_webkit_auth_file)
+        os.rmdir(svn_config_dir_path)
+        os.rmdir(fake_home_dir)
+
+    def test_not_have_authorization_for_realm(self):
+        scm = detect_scm_system(self.svn_checkout_path)
+        fake_home_dir = tempfile.mkdtemp(suffix="fake_home_dir")
+        svn_config_dir_path = os.path.join(fake_home_dir, ".subversion")
+        os.mkdir(svn_config_dir_path)
+        self.assertFalse(scm.has_authorization_for_realm(home_directory=fake_home_dir))
+        os.rmdir(svn_config_dir_path)
+        os.rmdir(fake_home_dir)
+
     def test_reverse_diff(self):
         self._shared_test_reverse_diff()
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list