Rev 4264: (Jelmer) Add UIFactory.get_username. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Apr 7 14:08:27 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4264
revision-id: pqm at pqm.ubuntu.com-20090407130821-e4wi39x60alhpnr4
parent: pqm at pqm.ubuntu.com-20090407104130-ka3rxokxvi9yfbck
parent: jelmer at samba.org-20090407124142-otgk4g0ibacgtmg1
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2009-04-07 14:08:21 +0100
message:
(Jelmer) Add UIFactory.get_username.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/test_ui.py test_ui.py-20051130162854-458e667a7414af09
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
------------------------------------------------------------
revno: 4222.2.12
revision-id: jelmer at samba.org-20090407124142-otgk4g0ibacgtmg1
parent: jelmer at samba.org-20090407115105-r7tx90v1ejqijf6y
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: ui-username
timestamp: Tue 2009-04-07 14:41:42 +0200
message:
Redirect to fix utf8 test with LC_ALL=C.
modified:
bzrlib/tests/test_ui.py test_ui.py-20051130162854-458e667a7414af09
------------------------------------------------------------
revno: 4222.2.11
revision-id: jelmer at samba.org-20090407115105-r7tx90v1ejqijf6y
parent: jelmer at samba.org-20090403174910-4zwhrn8ron8ba2f0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: ui-username
timestamp: Tue 2009-04-07 13:51:05 +0200
message:
Review feedback from vila: cope with stdin.readline() returning None, fix consistency in tests.
modified:
bzrlib/tests/test_ui.py test_ui.py-20051130162854-458e667a7414af09
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
------------------------------------------------------------
revno: 4222.2.10
revision-id: jelmer at samba.org-20090403174910-4zwhrn8ron8ba2f0
parent: jelmer at samba.org-20090403171939-1hnkorkxf633uyn5
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: ui-username
timestamp: Fri 2009-04-03 19:49:10 +0200
message:
Fix docstring.
modified:
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
------------------------------------------------------------
revno: 4222.2.9
revision-id: jelmer at samba.org-20090403171939-1hnkorkxf633uyn5
parent: jelmer at samba.org-20090402133658-4y971ttxdo9e6arc
parent: pqm at pqm.ubuntu.com-20090403164553-wo2n7k4nvd1xcyw3
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: ui-username
timestamp: Fri 2009-04-03 19:19:39 +0200
message:
Merge bzr.dev, including Vincents NotATerminal patch.
removed:
bzrlib/tests/blackbox/test_guess_renames.py test_guess_renames.p-20090312063936-bqdtxr0r3md3jc00-1
added:
bzrlib/filters/eol.py eol.py-20090327060429-todzdjmqt3bpv5r8-1
bzrlib/help_topics/en/eol.txt eol.txt-20090327060429-todzdjmqt3bpv5r8-3
bzrlib/inventory_delta.py journalled_inventory-20080103020931-0ht5n40kwc0p7fy1-1
bzrlib/tests/test_eol_filters.py test_eol_filters.py-20090327060429-todzdjmqt3bpv5r8-2
bzrlib/tests/test_inventory_delta.py test_journalled_inv.-20080103012121-ny2w9slze5jgty8i-1
bzrlib/tests/workingtree_implementations/test_eol_conversion.py test_eol_conversion.-20090327060429-todzdjmqt3bpv5r8-4
doc/developers/groupcompress-design.txt design-20080705181503-ccbxd6xuy1bdnrpu-2
modified:
.bzrignore bzrignore-20050311232317-81f7b71efa2db11a
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/__init__.py __init__.py-20050309040759-33e65acf91bbcd5d
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/bundle/serializer/v4.py v10.py-20070611062757-5ggj7k18s9dej0fr-1
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/commit.py commit.py-20050511101309-79ec1a0168e0e825
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/graph.py graph_walker.py-20070525030359-y852guab65d4wtn0-1
bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
bzrlib/help_topics/en/rules.txt rules.txt-20080516063844-ghr5l6pvvrhiycun-1
bzrlib/inventory.py inventory.py-20050309040759-6648b84ca2005b37
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/memorytree.py memorytree.py-20060906023413-4wlkalbdpsxi2r4y-1
bzrlib/mutabletree.py mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
bzrlib/osutils.py osutils.py-20050309040759-eeaff12fbf77ac86
bzrlib/reconcile.py reweave_inventory.py-20051108164726-1e5e0934febac06e
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/rename_map.py rename_map.py-20090312140439-xexkkmjlg2enbohc-1
bzrlib/repofmt/knitrepo.py knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repofmt/weaverepo.py presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/smart/branch.py branch.py-20061124031907-mzh3pla28r83r97f-1
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
bzrlib/tests/blackbox/test_add.py test_add.py-20060518072250-857e4f86f54a30b2
bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
bzrlib/tests/blackbox/test_filtered_view_ops.py test_filtered_view_o-20081110012645-5t7ogtola0l33lkg-1
bzrlib/tests/blackbox/test_mv.py test_mv.py-20060705114902-33tkxz0o9cdshemo-1
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/blackbox/test_view.py test_view.py-20080731135100-66o8o32heop7augi-1
bzrlib/tests/per_repository/test_add_inventory_by_delta.py test_add_inventory_d-20081013002626-rut81igtlqb4590z-1
bzrlib/tests/per_repository/test_check.py test_check.py-20070824124512-38g4d135gcqxo4zb-1
bzrlib/tests/per_repository/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
bzrlib/tests/per_repository_reference/test_add_inventory.py test_add_inventory.p-20080220025549-nnm2s80it1lvcwnc-3
bzrlib/tests/per_repository_reference/test_add_revision.py test_add_revision.py-20080220034108-ao1u8qgakqbo5a08-1
bzrlib/tests/per_repository_reference/test_add_signature_text.py test_add_signature_t-20080220041905-1j2g4lyz3c6h34v4-1
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
bzrlib/tests/test_http.py testhttp.py-20051018020158-b2eef6e867c514d9
bzrlib/tests/test_info.py test_info.py-20070320150933-m0xxm1g7xi9v6noe-1
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
bzrlib/tests/test_rename_map.py test_rename_map.py-20090312140439-xexkkmjlg2enbohc-2
bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
bzrlib/tests/workingtree_implementations/__init__.py __init__.py-20060203003124-b2aa5aca21a8bfad
bzrlib/transform.py transform.py-20060105172343-dd99e54394d91687
bzrlib/tree.py tree.py-20050309040759-9d5f2496be663e77
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
bzrlib/ui/text.py text.py-20051130153916-2e438cffc8afc478
bzrlib/versionedfile.py versionedfile.py-20060222045106-5039c71ee3b65490
bzrlib/weave.py knit.py-20050627021749-759c29984154256b
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
bzrlib/xml_serializer.py xml.py-20050309040759-57d51586fdec365d
doc/developers/development-repo.txt developmentrepo.txt-20080102200205-raj42k61dch8pjmj-1
doc/developers/index.txt index.txt-20070508041241-qznziunkg0nffhiw-1
doc/developers/inventory.txt inventory.txt-20080103013957-opkrhxy6lmywmx4i-1
doc/en/user-guide/filtered_views.txt filtered_views.txt-20090226100856-a16ba1v97v91ru58-1
tools/win32/build_release.py build_release.py-20081105204355-2ghh5cv01v1x4rzz-1
------------------------------------------------------------
revno: 4222.2.8
revision-id: jelmer at samba.org-20090402133658-4y971ttxdo9e6arc
parent: jelmer at samba.org-20090401171603-3cdysi1kd8kczhgl
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: ui-username
timestamp: Thu 2009-04-02 15:36:58 +0200
message:
Fix copy-n-paste error.
modified:
bzrlib/tests/test_ui.py test_ui.py-20051130162854-458e667a7414af09
------------------------------------------------------------
revno: 4222.2.7
revision-id: jelmer at samba.org-20090401171603-3cdysi1kd8kczhgl
parent: jelmer at samba.org-20090401164917-7jv92z0zxbe2tb5y
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: ui-username
timestamp: Wed 2009-04-01 19:16:03 +0200
message:
Add news item.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
------------------------------------------------------------
revno: 4222.2.6
revision-id: jelmer at samba.org-20090401164917-7jv92z0zxbe2tb5y
parent: jelmer at samba.org-20090401141618-t9yh0trnz8ril1xf
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: ui-username
timestamp: Wed 2009-04-01 18:49:17 +0200
message:
Remove use of NotATerminal.
modified:
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/test_ui.py test_ui.py-20051130162854-458e667a7414af09
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
------------------------------------------------------------
revno: 4222.2.5
revision-id: jelmer at samba.org-20090401141618-t9yh0trnz8ril1xf
parent: jelmer at samba.org-20090331204925-nti93kscqg3ej4cs
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: ui-username
timestamp: Wed 2009-04-01 16:16:18 +0200
message:
Duplicate behaviour for get_username() like we have for get_non_echoed_password().
modified:
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
------------------------------------------------------------
revno: 4222.2.4
revision-id: jelmer at samba.org-20090331204925-nti93kscqg3ej4cs
parent: jelmer at samba.org-20090331192242-a5cndihkf1l3s3wk
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: ui-username
timestamp: Tue 2009-03-31 22:49:25 +0200
message:
Clear terminal, remove check for isatty(), as it's not necessary for 'regular' prompting.
modified:
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
------------------------------------------------------------
revno: 4222.2.3
revision-id: jelmer at samba.org-20090331192242-a5cndihkf1l3s3wk
parent: jelmer at samba.org-20090331174456-jlmyoz4os4j74mqf
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: ui-username
timestamp: Tue 2009-03-31 21:22:42 +0200
message:
Also check for unicode usernames.
modified:
bzrlib/tests/test_ui.py test_ui.py-20051130162854-458e667a7414af09
------------------------------------------------------------
revno: 4222.2.2
revision-id: jelmer at samba.org-20090331174456-jlmyoz4os4j74mqf
parent: jelmer at samba.org-20090331135833-fpo4w8n5tco13z81
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: ui-username
timestamp: Tue 2009-03-31 19:44:56 +0200
message:
Review from vila: Deal with UTF8 strings in prompts, fix typo.
modified:
bzrlib/tests/test_ui.py test_ui.py-20051130162854-458e667a7414af09
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
------------------------------------------------------------
revno: 4222.2.1
revision-id: jelmer at samba.org-20090331135833-fpo4w8n5tco13z81
parent: pqm at pqm.ubuntu.com-20090331122525-77wqe7gqpr2gcl7u
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: username
timestamp: Tue 2009-03-31 15:58:33 +0200
message:
Add get_username() call to the UIFactory.
modified:
bzrlib/tests/test_ui.py test_ui.py-20051130162854-458e667a7414af09
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
=== modified file 'NEWS'
--- a/NEWS 2009-04-07 01:47:46 +0000
+++ b/NEWS 2009-04-07 13:08:21 +0000
@@ -194,6 +194,10 @@
commit - this was a full-tree overhead that bzr no longer performs.
(Robert Collins)
+* New abstract ``UIFactory`` method ``get_username`` which will be called to
+ obtain the username to use when connecting to remote machines.
+ (Jelmer Vernooij)
+
* New API ``Inventory.filter()`` added that filters an inventory by
a set of file-ids so that only those fileids, their parents and
their children are included. (Ian Clatworthy)
=== modified file 'bzrlib/tests/test_ui.py'
--- a/bzrlib/tests/test_ui.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/test_ui.py 2009-04-07 12:41:42 +0000
@@ -254,6 +254,44 @@
finally:
pb.finished()
+ def test_silent_ui_getusername(self):
+ factory = SilentUIFactory()
+ factory.stdin = StringIO("someuser\n\n")
+ factory.stdout = StringIO()
+ self.assertEquals(None,
+ factory.get_username(u'Hello\u1234 %(host)s', host=u'some\u1234'))
+ self.assertEquals("", factory.stdout.getvalue())
+ self.assertEquals("someuser\n\n", factory.stdin.getvalue())
+
+ def test_text_ui_getusername(self):
+ factory = TextUIFactory(None, None, None)
+ factory.stdin = StringIO("someuser\n\n")
+ factory.stdout = StringIO()
+ factory.stdout.encoding = "utf8"
+ # there is no output from the base factory
+ self.assertEqual("someuser",
+ factory.get_username('Hello %(host)s', host='some'))
+ self.assertEquals("Hello some: ", factory.stdout.getvalue())
+ self.assertEqual("", factory.get_username("Gebruiker"))
+ # stdin should be empty
+ self.assertEqual('', factory.stdin.readline())
+
+ def test_text_ui_getusername_utf8(self):
+ ui = TestUIFactory(stdin=u'someuser\u1234'.encode('utf8'),
+ stdout=StringIOWrapper())
+ ui.stdin.encoding = "utf8"
+ ui.stdout.encoding = ui.stdin.encoding
+ pb = ui.nested_progress_bar()
+ try:
+ # there is no output from the base factory
+ username = self.apply_redirected(ui.stdin, ui.stdout, ui.stdout,
+ ui.get_username, u'Hello\u1234 %(host)s', host=u'some\u1234')
+ self.assertEquals(u"someuser\u1234", username.decode('utf8'))
+ self.assertEquals(u"Hello\u1234 some\u1234: ",
+ ui.stdout.getvalue().decode("utf8"))
+ finally:
+ pb.finished()
+
class TestTextProgressView(TestCase):
"""Tests for text display of progress bars.
=== modified file 'bzrlib/ui/__init__.py'
--- a/bzrlib/ui/__init__.py 2009-04-02 17:41:41 +0000
+++ b/bzrlib/ui/__init__.py 2009-04-07 11:51:05 +0000
@@ -197,6 +197,25 @@
# as opposed to 'my password is empty' -- does it matter?
return self.get_non_echoed_password()
+ def get_username(self, prompt, **kwargs):
+ """Prompt the user for a username.
+
+ :param prompt: The prompt to present the user
+ :param kwargs: Arguments which will be expanded into the prompt.
+ This lets front ends display different things if
+ they so choose.
+ :return: The username string, return None if the user
+ canceled the request.
+ """
+ prompt += ': '
+ self.prompt(prompt, **kwargs)
+ username = self.stdin.readline()
+ if not username:
+ username = None
+ elif username[-1] == '\n':
+ username = username[:-1]
+ return username
+
def prompt(self, prompt, **kwargs):
"""Emit prompt on the CLI."""
prompt = prompt % kwargs
@@ -221,6 +240,9 @@
def get_password(self, prompt='', **kwargs):
return None
+ def get_username(self, prompt='', **kwargs):
+ return None
+
def prompt(self, prompt, **kwargs):
pass
More information about the bazaar-commits
mailing list