Changeset 84114 in webkit
- Timestamp:
- Apr 17, 2011 4:27:46 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r84112 r84114 1 2011-04-17 Daniel Bates <dbates@webkit.com> 2 3 Reviewed by Eric Seidel. 4 5 webkit-patch land hangs if svn prompts for credentials 6 https://bugs.webkit.org/show_bug.cgi?id=31500 7 8 Prompt for username and password when using git-svn and there aren't cached SVN credentials. 9 10 * Scripts/webkitpy/common/checkout/scm.py: 11 - Added mixin class SVNRepository and made both class SVN and Git inherit from it. 12 - Moved SVN.has_authorization_for_realm() to class SVNRepository and removed default value 13 for argument realm; modified call sites as needed. 14 - Modified AuthenticationError constructor to take optional prompt_for_password argument. 15 - Modified {SCM, SVN, Git}.commit_with_message() to take optional password argument. 16 - Modified Git._commit_on_branch() to take optional username and password argument. 17 - Modified Git.push_local_commits_to_server() to take optional username and password 18 argument and to call has_authorization_for_realm(). 19 * Scripts/webkitpy/common/checkout/scm_unittest.py: 20 - Modified SVNTest.test_commit_without_authorization() to take dummy realm argument. 21 - Modified SVNTest.test_not_have_authorization_for_realm() to pass realm argument to 22 SVN.has_authorization_for_realm(). 23 * Scripts/webkitpy/common/net/credentials.py: 24 - Modified Credentials.read_credentials() to call User.prompt_password() instead 25 of using getpass.getpass() directly. 26 * Scripts/webkitpy/common/system/user.py: 27 - Added User.prompt_password(). 28 * Scripts/webkitpy/tool/steps/commit.py: 29 - Modified Commit.run() to prompt for a password if needed. 30 1 31 2011-04-17 Dirk Pranke <dpranke@chromium.org> 2 32 -
trunk/Tools/Scripts/webkitpy/common/checkout/scm.py
r83614 r84114 135 135 136 136 class AuthenticationError(Exception): 137 def __init__(self, server_host ):137 def __init__(self, server_host, prompt_for_password=False): 138 138 self.server_host = server_host 139 self.prompt_for_password = prompt_for_password 139 140 140 141 … … 292 293 self._subclass_must_implement() 293 294 294 def commit_with_message(self, message, username=None, git_commit=None, force_squash=False, changed_files=None):295 def commit_with_message(self, message, username=None, password=None, git_commit=None, force_squash=False, changed_files=None): 295 296 self._subclass_must_implement() 296 297 … … 320 321 321 322 322 class SVN(SCM): 323 # A mixin class that represents common functionality for SVN and Git-SVN. 324 class SVNRepository: 325 def has_authorization_for_realm(self, realm, home_directory=os.getenv("HOME")): 326 # Assumes find and grep are installed. 327 if not os.path.isdir(os.path.join(home_directory, ".subversion")): 328 return False 329 find_args = ["find", ".subversion", "-type", "f", "-exec", "grep", "-q", realm, "{}", ";", "-print"] 330 find_output = self.run(find_args, cwd=home_directory, error_handler=Executive.ignore_error).rstrip() 331 return find_output and os.path.isfile(os.path.join(home_directory, find_output)) 332 333 334 class SVN(SCM, SVNRepository): 323 335 # FIXME: These belong in common.config.urls 324 336 svn_server_host = "svn.webkit.org" … … 374 386 def commit_success_regexp(): 375 387 return "^Committed revision (?P<svn_revision>\d+)\.$" 376 377 def has_authorization_for_realm(self, realm=svn_server_realm, home_directory=os.getenv("HOME")):378 # Assumes find and grep are installed.379 if not os.path.isdir(os.path.join(home_directory, ".subversion")):380 return False381 find_args = ["find", ".subversion", "-type", "f", "-exec", "grep", "-q", realm, "{}", ";", "-print"];382 find_output = self.run(find_args, cwd=home_directory, error_handler=Executive.ignore_error).rstrip()383 return find_output and os.path.isfile(os.path.join(home_directory, find_output))384 388 385 389 @memoized … … 557 561 self.run(['svn', 'revert'] + file_paths) 558 562 559 def commit_with_message(self, message, username=None, git_commit=None, force_squash=False, changed_files=None):563 def commit_with_message(self, message, username=None, password=None, git_commit=None, force_squash=False, changed_files=None): 560 564 # git-commit and force are not used by SVN. 561 565 svn_commit_args = ["svn", "commit"] 562 566 563 if not username and not self.has_authorization_for_realm( ):567 if not username and not self.has_authorization_for_realm(self.svn_server_realm): 564 568 raise AuthenticationError(self.svn_server_host) 565 569 if username: … … 599 603 600 604 # All git-specific logic should go here. 601 class Git(SCM ):605 class Git(SCM, SVNRepository): 602 606 def __init__(self, cwd, executive=None): 603 607 SCM.__init__(self, cwd, executive) … … 834 838 raise AmbiguousCommitError(num_local_commits, working_directory_is_clean) 835 839 836 def commit_with_message(self, message, username=None, git_commit=None, force_squash=False, changed_files=None):840 def commit_with_message(self, message, username=None, password=None, git_commit=None, force_squash=False, changed_files=None): 837 841 # Username is ignored during Git commits. 838 842 working_directory_is_clean = self.working_directory_is_clean() … … 844 848 raise ScriptError(message="The working copy is not modified. --git-commit=HEAD.. only commits working copy changes.") 845 849 self.commit_locally_with_message(message) 846 return self._commit_on_branch(message, 'HEAD' )850 return self._commit_on_branch(message, 'HEAD', username=username, password=password) 847 851 848 852 # Need working directory changes to be committed so we can checkout the merge branch. … … 852 856 # The ChangeLog modification could be made to modify the existing local commit. 853 857 raise ScriptError(message="Working copy is modified. Cannot commit individual git_commits.") 854 return self._commit_on_branch(message, git_commit )858 return self._commit_on_branch(message, git_commit, username=username, password=password) 855 859 856 860 if not force_squash: … … 858 862 self.run(['git', 'reset', '--soft', self.remote_merge_base()]) 859 863 self.commit_locally_with_message(message) 860 return self.push_local_commits_to_server( )861 862 def _commit_on_branch(self, message, git_commit ):864 return self.push_local_commits_to_server(username=username, password=password) 865 866 def _commit_on_branch(self, message, git_commit, username=None, password=None): 863 867 branch_ref = self.run(['git', 'symbolic-ref', 'HEAD']).strip() 864 868 branch_name = branch_ref.replace('refs/heads/', '') … … 889 893 890 894 self.run(['git', 'commit', '-m', message]) 891 output = self.push_local_commits_to_server( )895 output = self.push_local_commits_to_server(username=username, password=password) 892 896 except Exception, e: 893 897 log("COMMIT FAILED: " + str(e)) … … 937 941 self.run(['git', 'commit', '--all', '-F', '-'], input=message) 938 942 939 def push_local_commits_to_server(self ):943 def push_local_commits_to_server(self, username=None, password=None): 940 944 dcommit_command = ['git', 'svn', 'dcommit'] 941 945 if self.dryrun: 942 946 dcommit_command.append('--dry-run') 943 output = self.run(dcommit_command, error_handler=commit_error_handler) 947 if not self.has_authorization_for_realm(SVN.svn_server_realm): 948 raise AuthenticationError(SVN.svn_server_host, prompt_for_password=True) 949 if username: 950 dcommit_command.extend(["--username", username]) 951 output = self.run(dcommit_command, error_handler=commit_error_handler, input=password) 944 952 # Return a string which looks like a commit so that things which parse this output will succeed. 945 953 if self.dryrun: -
trunk/Tools/Scripts/webkitpy/common/checkout/scm_unittest.py
r83152 r84114 665 665 666 666 def test_commit_without_authorization(self): 667 self.scm.has_authorization_for_realm = lambda : False667 self.scm.has_authorization_for_realm = lambda realm: False 668 668 self.assertRaises(AuthenticationError, self._shared_test_commit_with_message) 669 669 … … 675 675 fake_webkit_auth_file = os.path.join(svn_config_dir_path, "fake_webkit_auth_file") 676 676 write_into_file_at_path(fake_webkit_auth_file, SVN.svn_server_realm) 677 self.assertTrue(scm.has_authorization_for_realm( home_directory=fake_home_dir))677 self.assertTrue(scm.has_authorization_for_realm(SVN.svn_server_realm, home_directory=fake_home_dir)) 678 678 os.remove(fake_webkit_auth_file) 679 679 os.rmdir(svn_config_dir_path) … … 685 685 svn_config_dir_path = os.path.join(fake_home_dir, ".subversion") 686 686 os.mkdir(svn_config_dir_path) 687 self.assertFalse(scm.has_authorization_for_realm( home_directory=fake_home_dir))687 self.assertFalse(scm.has_authorization_for_realm(SVN.svn_server_realm, home_directory=fake_home_dir)) 688 688 os.rmdir(svn_config_dir_path) 689 689 os.rmdir(fake_home_dir) -
trunk/Tools/Scripts/webkitpy/common/net/credentials.py
r70640 r84114 30 30 # Python module for reading stored web credentials from the OS. 31 31 32 import getpass33 32 import os 34 33 import platform … … 150 149 username = User.prompt("%s login: " % self.host) 151 150 if not password: 152 password = getpass.getpass("%s password for %s: " % (self.host, username))151 password = User.prompt_password("%s password for %s: " % (self.host, username)) 153 152 self._offer_to_store_credentials_in_keyring(username, password) 154 153 -
trunk/Tools/Scripts/webkitpy/common/system/user.py
r73838 r84114 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 import getpass 29 30 import logging 30 31 import os … … 64 65 response = raw_input(message) 65 66 return response 67 68 @classmethod 69 def prompt_password(cls, message, repeat=1): 70 return cls.prompt(message, repeat=repeat, raw_input=getpass.getpass) 66 71 67 72 @classmethod -
trunk/Tools/Scripts/webkitpy/tool/steps/commit.py
r82407 r84114 51 51 52 52 username = None 53 password = None 53 54 force_squash = False 54 55 … … 59 60 try: 60 61 scm = self._tool.scm() 61 commit_text = scm.commit_with_message(self._commit_message, git_commit=self._options.git_commit, username=username, force_squash=force_squash, changed_files=self._changed_files(state))62 commit_text = scm.commit_with_message(self._commit_message, git_commit=self._options.git_commit, username=username, password=password, force_squash=force_squash, changed_files=self._changed_files(state)) 62 63 svn_revision = scm.svn_revision_from_commit_text(commit_text) 63 64 log("Committed r%s: <%s>" % (svn_revision, urls.view_revision_url(svn_revision))) … … 73 74 username = self._tool.user.prompt("%s login: " % e.server_host, repeat=5) 74 75 if not username: 75 raise ScriptError("You need to specify the username on %s to perform the commit as." % self.svn_server_host) 76 raise ScriptError("You need to specify the username on %s to perform the commit as." % e.server_host) 77 if e.prompt_for_password: 78 password = self._tool.user.prompt_password("%s password for %s: " % (e.server_host, username), repeat=5) 79 if not password: 80 raise ScriptError("You need to specify the password for %s on %s to perform the commit." % (username, e.server_host))
Note: See TracChangeset
for help on using the changeset viewer.