[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373
dbates at webkit.org
dbates at webkit.org
Thu Apr 8 01:45:40 UTC 2010
The following commit has been merged in the webkit-1.2 branch:
commit fd84223e5e6a682c7786a6e88108a5629598fd08
Author: dbates at webkit.org <dbates at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Feb 12 01:59:02 2010 +0000
2010-02-11 Daniel Bates <dbates at rim.com>
Reviewed by Adam Barth.
https://bugs.webkit.org/show_bug.cgi?id=34830
Makes method User.prompt static and adds the parameter repeat
to prompt the user up to repeat times.
* Scripts/test-webkitpy:
* Scripts/webkitpy/bugzilla.py: Substituted method User.prompt for method raw_input.
* Scripts/webkitpy/commands/upload.py: Ditto
* Scripts/webkitpy/credentials.py: Ditto
* Scripts/mock_bugzillatool.py: Updated prototype of MockUser.prompt to match User.prompt.
* Scripts/webkitpy/user.py: Made method prompt static and added parameter repeat.
* Scripts/webkitpy/user_unittest.py: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54693 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 7505ad1..8deecb3 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,20 @@
+2010-02-11 Daniel Bates <dbates at rim.com>
+
+ Reviewed by Adam Barth.
+
+ https://bugs.webkit.org/show_bug.cgi?id=34830
+
+ Makes method User.prompt static and adds the parameter repeat
+ to prompt the user up to repeat times.
+
+ * Scripts/test-webkitpy:
+ * Scripts/webkitpy/bugzilla.py: Substituted method User.prompt for method raw_input.
+ * Scripts/webkitpy/commands/upload.py: Ditto
+ * Scripts/webkitpy/credentials.py: Ditto
+ * Scripts/mock_bugzillatool.py: Updated prototype of MockUser.prompt to match User.prompt.
+ * Scripts/webkitpy/user.py: Made method prompt static and added parameter repeat.
+ * Scripts/webkitpy/user_unittest.py: Added.
+
2010-02-10 Yuzo Fujishima <yuzo at google.com>
Reviewed by Darin Adler.
diff --git a/WebKitTools/Scripts/test-webkitpy b/WebKitTools/Scripts/test-webkitpy
index 98aee37..cfd3434 100755
--- a/WebKitTools/Scripts/test-webkitpy
+++ b/WebKitTools/Scripts/test-webkitpy
@@ -52,6 +52,7 @@ from webkitpy.steps.steps_unittest import *
from webkitpy.steps.closebugforlanddiff_unittest import *
from webkitpy.steps.updatechangelogswithreview_unittests import *
from webkitpy.style.unittests import * # for check-webkit-style
+from webkitpy.user_unittest import *
from webkitpy.webkit_logging_unittest import *
from webkitpy.webkitport_unittest import *
diff --git a/WebKitTools/Scripts/webkitpy/bugzilla.py b/WebKitTools/Scripts/webkitpy/bugzilla.py
index c1cf41d..4506af2 100644
--- a/WebKitTools/Scripts/webkitpy/bugzilla.py
+++ b/WebKitTools/Scripts/webkitpy/bugzilla.py
@@ -39,6 +39,7 @@ from datetime import datetime # used in timestamp()
from webkitpy.webkit_logging import error, log
from webkitpy.committers import CommitterList
from webkitpy.credentials import Credentials
+from webkitpy.user import User
# WebKit includes a built copy of BeautifulSoup in Scripts/webkitpy
# so this import should always succeed.
@@ -559,7 +560,7 @@ class Bugzilla(object):
for name in components:
i += 1
log("%2d. %s" % (i, name))
- result = int(raw_input("Enter a number: ")) - 1
+ result = int(User.prompt("Enter a number: ")) - 1
return components[result]
def _check_create_bug_response(self, response_html):
diff --git a/WebKitTools/Scripts/webkitpy/commands/upload.py b/WebKitTools/Scripts/webkitpy/commands/upload.py
index aeba134..15bdfbb 100644
--- a/WebKitTools/Scripts/webkitpy/commands/upload.py
+++ b/WebKitTools/Scripts/webkitpy/commands/upload.py
@@ -45,6 +45,7 @@ from webkitpy.grammar import pluralize, join_with_separators
from webkitpy.webkit_logging import error, log
from webkitpy.mock import Mock
from webkitpy.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.user import User
class CommitMessageForCurrentDiff(AbstractDeclarativeCommand):
name = "commit-message"
@@ -423,7 +424,7 @@ class CreateBug(AbstractDeclarativeCommand):
bug_id = tool.bugs.create_bug(bug_title, comment_text, options.component, diff_file, "Patch", cc=options.cc, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)
def prompt_for_bug_title_and_comment(self):
- bug_title = raw_input("Bug title: ")
+ bug_title = User.prompt("Bug title: ")
print "Bug comment (hit ^D on blank line to end):"
lines = sys.stdin.readlines()
try:
diff --git a/WebKitTools/Scripts/webkitpy/credentials.py b/WebKitTools/Scripts/webkitpy/credentials.py
index a4d8e34..295c576 100644
--- a/WebKitTools/Scripts/webkitpy/credentials.py
+++ b/WebKitTools/Scripts/webkitpy/credentials.py
@@ -37,6 +37,7 @@ import re
from webkitpy.executive import Executive, ScriptError
from webkitpy.webkit_logging import log
from webkitpy.scm import Git
+from webkitpy.user import User
class Credentials(object):
@@ -124,7 +125,7 @@ class Credentials(object):
(username, password) = self._credentials_from_keychain(username)
if not username:
- username = raw_input("%s login: " % self.host)
+ username = User.prompt("%s login: " % self.host)
if not password:
password = getpass.getpass("%s password for %s: " % (self.host,
username))
diff --git a/WebKitTools/Scripts/webkitpy/mock_bugzillatool.py b/WebKitTools/Scripts/webkitpy/mock_bugzillatool.py
index 1aff53a..f522e40 100644
--- a/WebKitTools/Scripts/webkitpy/mock_bugzillatool.py
+++ b/WebKitTools/Scripts/webkitpy/mock_bugzillatool.py
@@ -321,7 +321,8 @@ class MockSCM(Mock):
class MockUser(object):
- def prompt(self, message):
+ @staticmethod
+ def prompt(message, repeat=1, raw_input=raw_input):
return "Mock user response"
def edit(self, files):
diff --git a/WebKitTools/Scripts/webkitpy/user.py b/WebKitTools/Scripts/webkitpy/user.py
index 8dbf74c..b2ec19e 100644
--- a/WebKitTools/Scripts/webkitpy/user.py
+++ b/WebKitTools/Scripts/webkitpy/user.py
@@ -32,8 +32,13 @@ import subprocess
import webbrowser
class User(object):
- def prompt(self, message):
- return raw_input(message)
+ @staticmethod
+ def prompt(message, repeat=1, raw_input=raw_input):
+ response = None
+ while (repeat and not response):
+ repeat -= 1
+ response = raw_input(message)
+ return response
def edit(self, files):
editor = os.environ.get("EDITOR") or "vi"
diff --git a/WebKitTools/Scripts/webkitpy/user_unittest.py b/WebKitTools/Scripts/webkitpy/user_unittest.py
new file mode 100644
index 0000000..34d9983
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/user_unittest.py
@@ -0,0 +1,53 @@
+# Copyright (C) 2010 Research in Motion Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Research in Motion Ltd. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import unittest
+from webkitpy.user import User
+
+class UserTest(unittest.TestCase):
+
+ example_user_response = "example user response"
+
+ def test_prompt_repeat(self):
+ self.repeatsRemaining = 2
+ def mock_raw_input(message):
+ self.repeatsRemaining -= 1
+ if not self.repeatsRemaining:
+ return UserTest.example_user_response
+ return None
+ self.assertEqual(User.prompt("input", repeat=self.repeatsRemaining, raw_input=mock_raw_input), UserTest.example_user_response)
+
+ def test_prompt_when_exceeded_repeats(self):
+ self.repeatsRemaining = 2
+ def mock_raw_input(message):
+ self.repeatsRemaining -= 1
+ return None
+ self.assertEqual(User.prompt("input", repeat=self.repeatsRemaining, raw_input=mock_raw_input), None)
+
+if __name__ == '__main__':
+ unittest.main()
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list