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

Proposed by Martin Pool on 2009-04-24
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 2009-04-24 Pending
Review via email: mp+5861@code.launchpad.net
To post a comment you must log in.
Martin Pool (mbp) wrote :

Straightforward bug fix

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.

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/>

lp:~mbp/bzr/trivial-old updated on 2009-04-24
4303. By Canonical.com Patch Queue Manager <email address hidden> on 2009-04-24

(mbp) fix problem with prompting in break-lock

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2009-04-21 23:54:16 +0000
3+++ NEWS 2009-04-24 16:35:12 +0000
4@@ -38,6 +38,9 @@
5 * End-Of-Line content filters are now loaded correctly.
6 (Ian Clatworthy, Brian de Alwis, #355280)
7
8+* Fix TypeError in running ``bzr break-lock`` on some URLs.
9+ (Alexander Belchenko, Martin Pool, #365891)
10+
11 * ``bzr send`` works to send emails again using MAPI.
12 (Neil Martinsen-Burrell, #346998)
13
14
15=== modified file 'bzrlib/tests/test_ui.py'
16--- bzrlib/tests/test_ui.py 2009-04-07 12:41:42 +0000
17+++ bzrlib/tests/test_ui.py 2009-04-24 16:35:12 +0000
18@@ -221,6 +221,11 @@
19 factory = TextUIFactory(None, None, None)
20 self.assert_get_bool_acceptance_of_user_input(factory)
21
22+ def test_text_factory_prompt(self):
23+ # see <https://launchpad.net/bugs/365891>
24+ factory = TextUIFactory(None, StringIO(), StringIO())
25+ factory.prompt('foo %2e')
26+
27 def test_text_factory_prompts_and_clears(self):
28 # a get_boolean call should clear the pb before prompting
29 out = _TTYStringIO()
30
31=== modified file 'bzrlib/ui/__init__.py'
32--- bzrlib/ui/__init__.py 2009-04-07 11:51:05 +0000
33+++ bzrlib/ui/__init__.py 2009-04-24 16:35:12 +0000
34@@ -217,8 +217,14 @@
35 return username
36
37 def prompt(self, prompt, **kwargs):
38- """Emit prompt on the CLI."""
39- prompt = prompt % kwargs
40+ """Emit prompt on the CLI.
41+
42+ :param kwargs: Dictionary of arguments to insert into the prompt,
43+ to allow UIs to reformat the prompt.
44+ """
45+ if kwargs:
46+ # See <https://launchpad.net/bugs/365891>
47+ prompt = prompt % kwargs
48 prompt = prompt.encode(osutils.get_terminal_encoding(), 'replace')
49 self.clear_term()
50 self.stdout.write(prompt)