mercurial/admin_commands.py
author Joerg Sonnenberger <joerg@bec.de>
Mon, 08 Jul 2024 22:46:04 +0200
changeset 51896 8583d138f436
parent 51864 1c5810ce737e
permissions -rw-r--r--
exchange: improve computation of relevant markers for large repos Compute the candidate nodes with relevant markers directly from keys of the predecessors/successors/children dictionaries of obsstore. This is faster than iterating over all nodes directly. This test could be further improved for repositories with relative few markers compared to the repository size, but this is no longer hot already. With the current loop structure, the obshashrange use works as well as before as it passes lists with a single node. Adjust the interface by allowing revision lists as well as node lists. This helps cases that computes ancestors as it reduces the materialisation cost. Use this in _pushdiscoveryobsmarker and _getbundleobsmarkerpart. Improve the latter further by directly using ancestors(). Performance benchmarks show notable and welcome improvement to no-op push and pull (that would also apply to other push/pull). This apply to push and pull done without evolve. ### push/pull Benchmark parameter # bin-env-vars.hg.flavor = default # benchmark.variants.explicit-rev = none # benchmark.variants.protocol = ssh # benchmark.variants.revs = none ## benchmark.name = hg.command.pull # data-env-vars.name = mercurial-devel-2024-03-22-zstd-sparse-revlog before: 5.968537 seconds after: 5.668507 seconds (-5.03%, -0.30) # data-env-vars.name = tryton-devel-2024-03-22-zstd-sparse-revlog before: 1.446232 seconds after: 0.835553 seconds (-42.23%, -0.61) # data-env-vars.name = netbsd-src-draft-2024-09-19-zstd-sparse-revlog before: 5.777412 seconds after: 2.523454 seconds (-56.32%, -3.25) ## benchmark.name = hg.command.push # data-env-vars.name = mercurial-devel-2024-03-22-zstd-sparse-revlog before: 6.155501 seconds after: 5.885072 seconds (-4.39%, -0.27) # data-env-vars.name = tryton-devel-2024-03-22-zstd-sparse-revlog before: 1.491054 seconds after: 0.934882 seconds (-37.30%, -0.56) # data-env-vars.name = netbsd-src-draft-2024-09-19-zstd-sparse-revlog before: 5.902494 seconds after: 2.957644 seconds (-49.89%, -2.94) There is not notable different in these result using the "rust" flavor instead of the "default". The performance impact on the same operation when using evolve were also tested and no impact was noted.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50987
727428c7e1fc commands: add admin namespace
Franck Bret <franck.bret@octobus.net>
parents:
diff changeset
     1
# admin_commands.py - command processing for admin* commands
727428c7e1fc commands: add admin namespace
Franck Bret <franck.bret@octobus.net>
parents:
diff changeset
     2
#
727428c7e1fc commands: add admin namespace
Franck Bret <franck.bret@octobus.net>
parents:
diff changeset
     3
# Copyright 2022 Mercurial Developers
727428c7e1fc commands: add admin namespace
Franck Bret <franck.bret@octobus.net>
parents:
diff changeset
     4
#
727428c7e1fc commands: add admin namespace
Franck Bret <franck.bret@octobus.net>
parents:
diff changeset
     5
# This software may be used and distributed according to the terms of the
727428c7e1fc commands: add admin namespace
Franck Bret <franck.bret@octobus.net>
parents:
diff changeset
     6
# GNU General Public License version 2 or any later version.
727428c7e1fc commands: add admin namespace
Franck Bret <franck.bret@octobus.net>
parents:
diff changeset
     7
51864
1c5810ce737e typing: add `from __future__ import annotations` to remaining source files
Matt Harbison <matt_harbison@yahoo.com>
parents: 51615
diff changeset
     8
from __future__ import annotations
1c5810ce737e typing: add `from __future__ import annotations` to remaining source files
Matt Harbison <matt_harbison@yahoo.com>
parents: 51615
diff changeset
     9
50989
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    10
from .i18n import _
51503
d4095f7b000a admin-commands: move the chainsaw extension to the admin commands module
Raphaël Gomès <rgomes@octobus.net>
parents: 50989
diff changeset
    11
from .admin import chainsaw, verify
50989
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    12
from . import error, registrar, transaction
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    13
50987
727428c7e1fc commands: add admin namespace
Franck Bret <franck.bret@octobus.net>
parents:
diff changeset
    14
727428c7e1fc commands: add admin namespace
Franck Bret <franck.bret@octobus.net>
parents:
diff changeset
    15
table = {}
51503
d4095f7b000a admin-commands: move the chainsaw extension to the admin commands module
Raphaël Gomès <rgomes@octobus.net>
parents: 50989
diff changeset
    16
table.update(chainsaw.command._table)
50987
727428c7e1fc commands: add admin namespace
Franck Bret <franck.bret@octobus.net>
parents:
diff changeset
    17
command = registrar.command(table)
50989
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    18
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    19
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    20
@command(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    21
    b'admin::verify',
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    22
    [
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    23
        (b'c', b'check', [], _(b'add a check'), _(b'CHECK')),
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    24
        (b'o', b'option', [], _(b'pass an option to a check'), _(b'OPTION')),
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    25
    ],
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    26
    helpcategory=command.CATEGORY_MAINTENANCE,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    27
)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    28
def admin_verify(ui, repo, **opts):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    29
    """verify the integrity of the repository
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    30
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    31
    Alternative UI to `hg verify` with a lot more control over the
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    32
    verification process and better error reporting.
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    33
    """
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    34
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    35
    if not repo.url().startswith(b'file:'):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    36
        raise error.Abort(_(b"cannot verify bundle or remote repos"))
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    37
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    38
    if transaction.has_abandoned_transaction(repo):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    39
        ui.warn(_(b"abandoned transaction found - run hg recover\n"))
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    40
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    41
    checks = opts.get("check", [])
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    42
    options = opts.get("option", [])
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    43
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    44
    funcs = verify.get_checks(repo, ui, names=checks, options=options)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    45
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    46
    ui.status(_(b"running %d checks\n") % len(funcs))
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    47
    # Done in two times so the execution is separated from the resolving step
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    48
    for name, func in sorted(funcs.items(), key=lambda x: x[0]):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    49
        ui.status(_(b"running %s\n") % name)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    50
        errors = func()
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents: 50987
diff changeset
    51
        if errors:
51615
a93e60ebea09 admin-verify: expect a number of errors to be returned
Raphaël Gomès <rgomes@octobus.net>
parents: 51503
diff changeset
    52
            ui.warn(_(b"found %d errors\n") % errors)