Bug 1736950 - Fix mach show-log after bug 1696251. r=firefox-build-system-reviewers,mhentges

And disable logging on mach clobber like before.

Differential Revision: https://phabricator.services.mozilla.com/D129104
This commit is contained in:
Mike Hommey 2021-10-22 04:33:04 +00:00
Родитель 07f62cc951
Коммит 23737c4854
3 изменённых файлов: 16 добавлений и 8 удалений

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

@ -43,6 +43,8 @@ class _MachCommand(object):
# For subcommands, the global order that the subcommand's declaration
# was seen.
"decl_order",
# Whether to disable automatic logging to last_log.json for the command.
"no_auto_log",
)
def __init__(
@ -56,6 +58,7 @@ class _MachCommand(object):
order=None,
virtualenv_name=None,
ok_if_tests_disabled=False,
no_auto_log=False,
):
self.name = name
self.subcommand = subcommand
@ -77,6 +80,7 @@ class _MachCommand(object):
self.metrics_path = None
self.subcommand_handlers = {}
self.decl_order = None
self.no_auto_log = no_auto_log
def create_instance(self, context, virtualenv_name):
metrics = None
@ -86,7 +90,12 @@ class _MachCommand(object):
# This ensures the resulting class is defined inside `mach` so that logging
# works as expected, and has a meaningful name
subclass = type(self.name, (MachCommandBase,), {})
return subclass(context, virtualenv_name=virtualenv_name, metrics=metrics)
return subclass(
context,
virtualenv_name=virtualenv_name,
metrics=metrics,
no_auto_log=self.no_auto_log,
)
@property
def parser(self):

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

@ -896,7 +896,7 @@ class MachCommandBase(MozbuildObject):
without having to change everything that inherits from it.
"""
def __init__(self, context, virtualenv_name=None, metrics=None):
def __init__(self, context, virtualenv_name=None, metrics=None, no_auto_log=False):
# Attempt to discover topobjdir through environment detection, as it is
# more reliable than mozconfig when cwd is inside an objdir.
topsrcdir = context.topdir
@ -970,7 +970,7 @@ class MachCommandBase(MozbuildObject):
fileno = getattr(sys.stdout, "fileno", lambda: None)()
except io.UnsupportedOperation:
fileno = None
if fileno and os.isatty(fileno) and not getattr(self, "NO_AUTO_LOG", False):
if fileno and os.isatty(fileno) and not no_auto_log:
self._ensure_state_subdir_exists(".")
logfile = self._get_state_filename("last_log.json")
try:

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

@ -216,7 +216,6 @@ def doctor(command_context, fix=False, verbose=False):
)
NO_AUTO_LOG = True
CLOBBER_CHOICES = {"objdir", "python", "gradle"}
@ -224,6 +223,7 @@ CLOBBER_CHOICES = {"objdir", "python", "gradle"}
"clobber",
category="build",
description="Clobber the tree (delete the object directory).",
no_auto_log=True,
)
@CommandArgument(
"what",
@ -332,10 +332,9 @@ def clobber(command_context, what, full=False):
return ret
NO_AUTO_LOG = True
@Command("show-log", category="post-build", description="Display mach logs")
@Command(
"show-log", category="post-build", description="Display mach logs", no_auto_log=True
)
@CommandArgument(
"log_file",
nargs="?",