##// END OF EJS Templates
tests: enforce the use of `from __future__ import annotations`...
tests: enforce the use of `from __future__ import annotations` A recent MR and a separate recently landed MR that extracted code to a new file overlooked this, so I think it's worth flagging to ensure consistency. We don't enforce the import for empty files (like `__init__.py`). I'd rather this go into `import-checker.py`, but the import of interest only happens at the top of the file, and its `verify_modern_convention()` calls itself recursively as it transits the AST where the annotations might be. After a few hours of hacking on trying to get it to enforce the import, but only if annotations are used in the module (we generally don't have or check annotations in test files, so don't need this import), I gave up and resorted to this. It won't handle multi-line imports, but this isn't something I'd expect to change often, so this is good enough for now.

File last commit:

r52757:1c5810ce default
r53246:662b08ac default
Show More
admin_commands.py
52 lines | 1.6 KiB | text/x-python | PythonLexer
# admin_commands.py - command processing for admin* commands
#
# Copyright 2022 Mercurial Developers
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import annotations
from .i18n import _
from .admin import chainsaw, verify
from . import error, registrar, transaction
table = {}
table.update(chainsaw.command._table)
command = registrar.command(table)
@command(
b'admin::verify',
[
(b'c', b'check', [], _(b'add a check'), _(b'CHECK')),
(b'o', b'option', [], _(b'pass an option to a check'), _(b'OPTION')),
],
helpcategory=command.CATEGORY_MAINTENANCE,
)
def admin_verify(ui, repo, **opts):
"""verify the integrity of the repository
Alternative UI to `hg verify` with a lot more control over the
verification process and better error reporting.
"""
if not repo.url().startswith(b'file:'):
raise error.Abort(_(b"cannot verify bundle or remote repos"))
if transaction.has_abandoned_transaction(repo):
ui.warn(_(b"abandoned transaction found - run hg recover\n"))
checks = opts.get("check", [])
options = opts.get("option", [])
funcs = verify.get_checks(repo, ui, names=checks, options=options)
ui.status(_(b"running %d checks\n") % len(funcs))
# Done in two times so the execution is separated from the resolving step
for name, func in sorted(funcs.items(), key=lambda x: x[0]):
ui.status(_(b"running %s\n") % name)
errors = func()
if errors:
ui.warn(_(b"found %d errors\n") % errors)