Merge lp:~mbp/bzr/trivial-old into lp:~bzr/bzr/trunk-old

Proposed by Martin Pool
Status: Merged
Merged at revision: not available
Proposed branch: lp:~mbp/bzr/trivial-old
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 50 lines
To merge this branch: bzr merge lp:~mbp/bzr/trivial-old
Reviewer Review Type Date Requested Status
Bazaar Developers Pending
Review via email: mp+5861@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

Straightforward bug fix

Revision history for this message
John A Meinel (jameinel) wrote :

It was fully intentional that prompt expands its arguments rather than passing it in.

Specifically, the idea was that a GUI may decide to completely change how it wants to represent the information. And in that case the 'prompt' just becomes the key that can be used to map into what dialog you want to display.

For example, if I was writing a GUI, I might actually display:

Please supply a password for:
  $HOST
Username: [ ]
Password: [ ]

Etc. Rather than directly using the string supplied. That may not be clear enough in the docs.

Anyway, :approve of the patch.

Revision history for this message
Martin Pool (mbp) wrote :

2009/4/24 John A Meinel <email address hidden>:
> It was fully intentional that prompt expands its arguments rather than passing it in.
>
> Specifically, the idea was that a GUI may decide to completely change how it wants to represent the information. And in that case the 'prompt' just becomes the key that can be used to map into what dialog you want to display.

Of course; I'll update the comment appropriately.

--
Martin <http://launchpad.net/~mbp/>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-04-21 23:54:16 +0000
+++ NEWS 2009-04-24 16:35:12 +0000
@@ -38,6 +38,9 @@
38* End-Of-Line content filters are now loaded correctly.38* End-Of-Line content filters are now loaded correctly.
39 (Ian Clatworthy, Brian de Alwis, #355280)39 (Ian Clatworthy, Brian de Alwis, #355280)
4040
41* Fix TypeError in running ``bzr break-lock`` on some URLs.
42 (Alexander Belchenko, Martin Pool, #365891)
43
41* ``bzr send`` works to send emails again using MAPI.44* ``bzr send`` works to send emails again using MAPI.
42 (Neil Martinsen-Burrell, #346998)45 (Neil Martinsen-Burrell, #346998)
4346
4447
=== modified file 'bzrlib/tests/test_ui.py'
--- bzrlib/tests/test_ui.py 2009-04-07 12:41:42 +0000
+++ bzrlib/tests/test_ui.py 2009-04-24 16:35:12 +0000
@@ -221,6 +221,11 @@
221 factory = TextUIFactory(None, None, None)221 factory = TextUIFactory(None, None, None)
222 self.assert_get_bool_acceptance_of_user_input(factory)222 self.assert_get_bool_acceptance_of_user_input(factory)
223223
224 def test_text_factory_prompt(self):
225 # see <https://launchpad.net/bugs/365891>
226 factory = TextUIFactory(None, StringIO(), StringIO())
227 factory.prompt('foo %2e')
228
224 def test_text_factory_prompts_and_clears(self):229 def test_text_factory_prompts_and_clears(self):
225 # a get_boolean call should clear the pb before prompting230 # a get_boolean call should clear the pb before prompting
226 out = _TTYStringIO()231 out = _TTYStringIO()
227232
=== modified file 'bzrlib/ui/__init__.py'
--- bzrlib/ui/__init__.py 2009-04-07 11:51:05 +0000
+++ bzrlib/ui/__init__.py 2009-04-24 16:35:12 +0000
@@ -217,8 +217,14 @@
217 return username217 return username
218218
219 def prompt(self, prompt, **kwargs):219 def prompt(self, prompt, **kwargs):
220 """Emit prompt on the CLI."""220 """Emit prompt on the CLI.
221 prompt = prompt % kwargs221
222 :param kwargs: Dictionary of arguments to insert into the prompt,
223 to allow UIs to reformat the prompt.
224 """
225 if kwargs:
226 # See <https://launchpad.net/bugs/365891>
227 prompt = prompt % kwargs
222 prompt = prompt.encode(osutils.get_terminal_encoding(), 'replace')228 prompt = prompt.encode(osutils.get_terminal_encoding(), 'replace')
223 self.clear_term()229 self.clear_term()
224 self.stdout.write(prompt)230 self.stdout.write(prompt)