146
145
"This may take some time. Upgrade the repositories to the "
147
146
"same format for better performance."
149
experimental_format_fetch=("Fetching into experimental format "
151
"This format may be unreliable or change in the future "
152
"without an upgrade path.\n"),
154
"The command 'bzr %(deprecated_name)s' "
155
"has been deprecated in bzr %(deprecated_in_version)s. "
156
"Please use 'bzr %(recommended_name)s' instead."),
157
deprecated_command_option=(
158
"The option '%(deprecated_name)s' to 'bzr %(command)s' "
159
"has been deprecated in bzr %(deprecated_in_version)s. "
160
"Please use '%(recommended_name)s' instead."),
161
148
recommend_upgrade=("%(current_format_name)s is deprecated "
162
149
"and a better format is available.\n"
163
150
"It is recommended that you upgrade by "
164
151
"running the command\n"
165
152
" bzr upgrade %(basedir)s"),
167
u"Stole dead lock %(lock_url)s %(other_holder_info)s."),
170
155
def __init__(self):
216
201
return self.get_boolean(prompt % prompt_kwargs)
218
def get_password(self, prompt=u'', **kwargs):
203
def get_password(self, prompt='', **kwargs):
219
204
"""Prompt the user for a password.
221
:param prompt: The prompt to present the user (must be unicode)
206
:param prompt: The prompt to present the user
222
207
:param kwargs: Arguments which will be expanded into the prompt.
223
208
This lets front ends display different things if
314
301
template = self._user_warning_templates[warning_id]
316
fail = "bzr warning: %r, %r" % (warning_id, message_args)
317
warnings.warn("no template for warning: " + fail) # so tests will fail etc
303
fail = "failed to format warning %r, %r" % (warning_id, message_args)
304
warnings.warn(fail) # so tests will fail etc
320
307
return template % message_args
321
308
except ValueError, e:
322
fail = "bzr unprintable warning: %r, %r, %s" % (
309
fail = "failed to format warning %r, %r: %s" % (
323
310
warning_id, message_args, e)
324
311
warnings.warn(fail) # so tests will fail etc
327
def choose(self, msg, choices, default=None):
328
"""Prompt the user for a list of alternatives.
330
:param msg: message to be shown as part of the prompt.
332
:param choices: list of choices, with the individual choices separated
333
by '\n', e.g.: choose("Save changes?", "&Yes\n&No\n&Cancel"). The
334
letter after the '&' is the shortcut key for that choice. Thus you
335
can type 'c' to select "Cancel". Shorcuts are case insensitive.
336
The shortcut does not need to be the first letter. If a shorcut key
337
is not provided, the first letter for the choice will be used.
339
:param default: default choice (index), returned for example when enter
340
is pressed for the console version.
342
:return: the index fo the user choice (so '0', '1' or '2' for
343
respectively yes/no/cancel in the previous example).
345
raise NotImplementedError(self.choose)
347
314
def get_boolean(self, prompt):
348
315
"""Get a boolean question answered from the user.
350
317
:param prompt: a message to prompt the user with. Should be a single
351
line without terminating \\n.
318
line without terminating \n.
352
319
:return: True or False for y/yes or n/no.
354
choice = self.choose(prompt + '?', '&yes\n&no', default=None)
321
raise NotImplementedError(self.get_boolean)
357
323
def get_integer(self, prompt):
358
324
"""Get an integer from the user.
360
326
:param prompt: a message to prompt the user with. Could be a multi-line
361
prompt but without a terminating \\n.
327
prompt but without a terminating \n.
363
329
:return: A signed integer.
436
402
"""Show a warning to the user."""
437
403
raise NotImplementedError(self.show_warning)
405
def warn_cross_format_fetch(self, from_format, to_format):
406
"""Warn about a potentially slow cross-format transfer.
408
This is deprecated in favor of show_user_warning, but retained for api
409
compatibility in 2.0 and 2.1.
411
self.show_user_warning('cross_format_fetch', from_format=from_format,
414
def warn_experimental_format_fetch(self, inter):
415
"""Warn about fetching into experimental repository formats."""
416
if inter.target._format.experimental:
417
trace.warning("Fetching into experimental format %s.\n"
418
"This format may be unreliable or change in the future "
419
"without an upgrade path.\n" % (inter.target._format,))
440
422
class NoninteractiveUIFactory(UIFactory):
441
423
"""Base class for UIs with no user."""
497
479
def get_integer(self, prompt):
498
480
return self.responses.pop(0)
500
def get_password(self, prompt=u'', **kwargs):
482
def get_password(self, prompt='', **kwargs):
501
483
return self.responses.pop(0)
503
485
def get_username(self, prompt, **kwargs):