Bug 1530544 - Use consistent question style for prompt inside bootstrap and mercurial-setup. r=glandium

Changed the following:
  - Use (Yn) instead of [Y/n] to align with mercurial-setup that is using
    mercurial's ui class
  - Use (Yn) prompt instead of int prompt where the options are Yes/No
  - Remove empty lines around options to align with the first question
    about Firefox {Desktop,Mobile} {,non-}Artifact
  - Move the question `Would you like to enable build system telemetry?`
    to the last line
  - Use `Your choice:` propmt for int prompt to align with the first question

Differential Revision: https://phabricator.services.mozilla.com/D23457

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tooru Fujisawa 2019-03-19 08:02:05 +00:00
Родитель 96a6c6f371
Коммит 7cd514e655
4 изменённых файлов: 20 добавлений и 52 удалений

Просмотреть файл

@ -441,7 +441,7 @@ class BaseBootstrapper(object):
''' Prompts the user with prompt and requires a yes/no answer.'''
valid = False
while not valid:
choice = raw_input(prompt + ' [Y/n]: ').strip().lower()[:1]
choice = raw_input(prompt + ' (Yn): ').strip().lower()[:1]
if choice == '':
choice = 'y'
if choice not in ('y', 'n'):

Просмотреть файл

@ -78,12 +78,7 @@ If you would like to use a different directory, hit CTRL+c and set the
MOZBUILD_STATE_PATH environment variable to the directory you'd like to
use and re-run the bootstrapper.
Would you like to create this directory?
1. Yes
2. No
Your choice: '''
Would you like to create this directory? (Yn):'''
STYLO_NODEJS_DIRECTORY_MESSAGE = '''
Stylo and NodeJS packages require a directory to store shared, persistent
@ -124,23 +119,13 @@ Mozilla recommends a number of changes to Mercurial to enhance your
experience with it.
Would you like to run a configuration wizard to ensure Mercurial is
optimally configured?
1. Yes
2. No
Please enter your reply: '''
optimally configured?'''
CONFIGURE_GIT = '''
Mozilla recommends using git-cinnabar to work with mozilla-central.
Would you like to run a few configuration steps to ensure Git is
optimally configured?
1. Yes
2. No
Please enter your reply: '''
optimally configured?'''
CLONE_VCS = '''
If you would like to clone the {} {} repository, please
@ -150,16 +135,14 @@ enter the destination path below.
CLONE_VCS_PROMPT = '''
Destination directory for {} clone (leave empty to not clone): '''.lstrip()
CLONE_VCS_NOT_EMPTY = '''
CLONE_VCS_NOT_EMPTY = '''\
Destination directory '{}' is not empty.
Would you like to clone to '{}' instead?
1. Yes
2. No, let me enter another path
3. No, stop cloning
Please enter your reply: '''.lstrip()
Your choice: '''
CLONE_VCS_NOT_EMPTY_FALLBACK_FAILED = '''
ERROR! Destination directory '{}' is not empty and '{}' exists.
@ -195,7 +178,7 @@ Then restart your shell.
'''
TELEMETRY_OPT_IN_PROMPT = '''
Would you like to enable build system telemetry?
Build system telemetry
Mozilla collects data about local builds in order to make builds faster and
improve developer tooling. To learn more about the data we intend to collect
@ -205,7 +188,7 @@ https://firefox-source-docs.mozilla.org/build/buildsystem/telemetry.html.
If you have questions, please ask in #build in irc.mozilla.org. If you would
like to opt out of data collection, select (N) at the prompt.
Your choice'''
Would you like to enable build system telemetry?'''
def update_or_create_build_telemetry_config(path):
@ -302,7 +285,6 @@ class Bootstrapper(object):
repo_name = 'mozilla-unified'
vcs = 'Mercurial'
if not with_hg:
repo_name = 'gecko'
vcs = 'Git'
print(CLONE_VCS.format(repo_name, vcs))
@ -347,12 +329,8 @@ class Bootstrapper(object):
if not os.path.exists(state_dir):
should_create_state_dir = True
if not self.instance.no_interactive:
choice = self.instance.prompt_int(
prompt=STATE_DIR_INFO.format(statedir=state_dir),
low=1,
high=2)
should_create_state_dir = choice == 1
should_create_state_dir = self.instance.prompt_yesno(
prompt=STATE_DIR_INFO.format(statedir=state_dir))
# This directory is by default in $HOME, or overridden via an env
# var, so we probably shouldn't gate it on --no-system-changes.
@ -405,7 +383,7 @@ class Bootstrapper(object):
if self.choice is None:
# Like ['1. Firefox for Desktop', '2. Firefox for Android Artifact Mode', ...].
labels = ['%s. %s' % (i + 1, name) for (i, (name, _)) in enumerate(APPLICATIONS_LIST)]
prompt = APPLICATION_CHOICE % '\n'.join(labels)
prompt = APPLICATION_CHOICE % '\n'.join(' {}'.format(label) for label in labels)
prompt_choice = self.instance.prompt_int(prompt=prompt, low=1, high=len(APPLICATIONS))
name, application = APPLICATIONS_LIST[prompt_choice-1]
elif self.choice not in APPLICATIONS.keys():
@ -460,10 +438,7 @@ class Bootstrapper(object):
if hg_installed and state_dir_available and (checkout_type == 'hg' or self.vcs == 'hg'):
configure_hg = False
if not self.instance.no_interactive:
choice = self.instance.prompt_int(prompt=CONFIGURE_MERCURIAL,
low=1, high=2)
if choice == 1:
configure_hg = True
configure_hg = self.instance.prompt_yesno(prompt=CONFIGURE_MERCURIAL)
else:
configure_hg = self.hg_configure
@ -474,10 +449,7 @@ class Bootstrapper(object):
elif self.instance.which('git') and (checkout_type == 'git' or self.vcs == 'git'):
should_configure_git = False
if not self.instance.no_interactive:
choice = self.instance.prompt_int(prompt=CONFIGURE_GIT,
low=1, high=2)
if choice == 1:
should_configure_git = True
should_configure_git = self.instance.prompt_yesno(prompt=CONFIGURE_GIT)
else:
# Assuming default configuration setting applies to all VCS.
should_configure_git = self.hg_configure

Просмотреть файл

@ -19,13 +19,10 @@ Mercurial via the "pip" Python packaging utility. This will likely result
in files being placed in /usr/local/bin and /usr/local/lib.
How would you like to continue?
1) Install a modern Mercurial via pip (recommended)
2) Install a legacy Mercurial via apt
3) Do not install Mercurial
Choice:
'''.strip()
1. Install a modern Mercurial via pip (recommended)
2. Install a legacy Mercurial via apt
3. Do not install Mercurial
Your choice: '''
class DebianBootstrapper(NasmInstall, NodeInstall, StyloInstall, ClangStaticAnalysisInstall,

Просмотреть файл

@ -110,10 +110,9 @@ We will install a modern version of Clang through %s.
PACKAGE_MANAGER_CHOICE = '''
Please choose a package manager you'd like:
1. Homebrew
2. MacPorts (Does not yet support bootstrapping GeckoView/Firefox for Android.)
Your choice:
'''
1. Homebrew
2. MacPorts (Does not yet support bootstrapping GeckoView/Firefox for Android.)
Your choice: '''
NO_PACKAGE_MANAGER_WARNING = '''
It seems you don't have any supported package manager installed.