Skip to content

Commit

Permalink
configwizard: add a Python version check step (Bug 1742634) r=mhentges
Browse files Browse the repository at this point in the history
Adds a step to configwizard to detect if the interpreter running
Mercurial is Python 2. If it is, print a warning recommending upgrading
to Python 3.

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
cgsheeh committed Mar 29, 2022
1 parent 9847b70 commit 88a77e3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions hgext/configwizard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@
Would you like to fix the file permissions (Yn) $$ &Yes $$ &No
'''.strip()

PYTHON_VERSION_WARNING = b"""
Mercurial is installed into a Python 2 interpreter environment on
your machine. In the near future Python 2 will no longer be supported
by Mozilla or the upstream Mercurial project.
Please upgrade your Mercurial to a Python 3 interpreter.
""".strip()


testedwith = b'4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3'
buglink = b'https://bugzilla.mozilla.org/enter_bug.cgi?product=Developer%20Services&component=Mercurial%3A%20configwizard'
Expand Down Expand Up @@ -418,6 +426,7 @@ def _vcthome(): # Returns the directory where the vct clone is located

wizardsteps = set([
b'hgversion',
b'pyversion',
b'username',
b'tweakdefaults',
b'diff',
Expand Down Expand Up @@ -485,6 +494,9 @@ def configwizard(ui, repo, statedir=None, **opts):
if _checkhgversion(ui, hgversion):
return 1

if b"pyversion" in runsteps:
_checkpyversion(ui)

if b'username' in runsteps:
_checkusername(ui, cw)

Expand Down Expand Up @@ -597,6 +609,11 @@ def _checkhgversion(ui, hgversion):
if not uipromptchoice(ui, b'Would you like to exit to upgrade your Mercurial version (Yn)? $$ &Yes $$ &No'):
return 1

def _checkpyversion(ui):
"""Check the Python version for this install."""
if not pycompat.ispy3:
ui.warn(PYTHON_VERSION_WARNING)


def uiprompt(ui, msg, default=None):
"""Wrapper for ui.prompt() that only renders the last line of text as prompt.
Expand Down

0 comments on commit 88a77e3

Please sign in to comment.