annotate mercurial/admin/verify.py @ 51718:45828bc3c3d6

typing: add type hints to `mercurial.verify._normpath()` Since 10db46e128d4, pytype almost figured this out, going from `Any` -> `_T0`, but the intent is obvious.
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 18 Jul 2024 20:34:35 -0400
parents 2a27b921cd91
children 1c5810ce737e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50989
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
1 # admin/verify.py - better repository integrity checking for Mercurial
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
2 #
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
3 # Copyright 2023 Octobus <contact@octobus.net>
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
4 #
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
5 # This software may be used and distributed according to the terms of the
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
6 # GNU General Public License version 2 or any later version.
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
7
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
8 import collections
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
9 import copy
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
10 import functools
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
11
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
12 from ..i18n import _
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
13 from .. import error, pycompat, registrar, requirements
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
14 from ..utils import stringutil
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
15
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
16
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
17 verify_table = {}
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
18 verify_alias_table = {}
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
19 check = registrar.verify_check(verify_table, verify_alias_table)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
20
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
21
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
22 # Use this to declare options/aliases in the middle of the hierarchy.
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
23 # Checks like these are not run themselves and cannot have a body.
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
24 # For an example, see the `revlogs` check.
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
25 def noop_func(*args, **kwargs):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
26 return
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
27
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
28
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
29 @check(b"working-copy.dirstate", alias=b"dirstate")
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
30 def check_dirstate(ui, repo, **options):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
31 ui.status(_(b"checking dirstate\n"))
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
32
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
33 parent1, parent2 = repo.dirstate.parents()
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
34 m1 = repo[parent1].manifest()
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
35 m2 = repo[parent2].manifest()
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
36 errors = 0
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
37
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
38 is_narrow = requirements.NARROW_REQUIREMENT in repo.requirements
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
39 narrow_matcher = repo.narrowmatch() if is_narrow else None
51613
dcb00d5c397a admin-verify: pass p1 down to the dirstate function
Raphaël Gomès <rgomes@octobus.net>
parents: 50989
diff changeset
40 for err in repo.dirstate.verify(m1, m2, parent1, narrow_matcher):
51614
2a27b921cd91 admin-verify: fix error message handling
Raphaël Gomès <rgomes@octobus.net>
parents: 51613
diff changeset
41 ui.warn(err)
50989
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
42 errors += 1
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
43
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
44 return errors
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
45
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
46
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
47 # Tree of all checks and their associated function
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
48 pyramid = {}
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
49
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
50
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
51 def build_pyramid(table, full_pyramid):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
52 """Create a pyramid of checks of the registered checks.
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
53 It is a name-based hierarchy that can be arbitrarily nested."""
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
54 for entry, func in sorted(table.items(), key=lambda x: x[0], reverse=True):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
55 cursor = full_pyramid
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
56 levels = entry.split(b".")
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
57 for level in levels[:-1]:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
58 current_node = cursor.setdefault(level, {})
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
59 cursor = current_node
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
60 if cursor.get(levels[-1]) is None:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
61 cursor[levels[-1]] = (entry, func)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
62 elif func is not noop_func:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
63 m = b"intermediate checks need to use `verify.noop_func`"
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
64 raise error.ProgrammingError(m)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
65
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
66
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
67 def find_checks(name, table=None, alias_table=None, full_pyramid=None):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
68 """Find all checks for a given name and returns a dict of
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
69 (qualified_check_name, check_function)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
70
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
71 # Examples
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
72
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
73 Using a full qualified name:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
74 "working-copy.dirstate" -> {
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
75 "working-copy.dirstate": CF,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
76 }
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
77
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
78 Using a *prefix* of a qualified name:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
79 "store.revlogs" -> {
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
80 "store.revlogs.changelog": CF,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
81 "store.revlogs.manifestlog": CF,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
82 "store.revlogs.filelog": CF,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
83 }
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
84
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
85 Using a defined alias:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
86 "revlogs" -> {
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
87 "store.revlogs.changelog": CF,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
88 "store.revlogs.manifestlog": CF,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
89 "store.revlogs.filelog": CF,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
90 }
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
91
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
92 Using something that is none of the above will be an error.
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
93 """
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
94 if table is None:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
95 table = verify_table
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
96 if alias_table is None:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
97 alias_table = verify_alias_table
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
98
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
99 if name == b"full":
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
100 return table
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
101 checks = {}
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
102
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
103 # is it a full name?
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
104 check = table.get(name)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
105
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
106 if check is None:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
107 # is it an alias?
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
108 qualified_name = alias_table.get(name)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
109 if qualified_name is not None:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
110 name = qualified_name
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
111 check = table.get(name)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
112 else:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
113 split = name.split(b".", 1)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
114 if len(split) == 2:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
115 # split[0] can be an alias
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
116 qualified_name = alias_table.get(split[0])
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
117 if qualified_name is not None:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
118 name = b"%s.%s" % (qualified_name, split[1])
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
119 check = table.get(name)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
120 else:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
121 qualified_name = name
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
122
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
123 # Maybe it's a subtree in the check hierarchy that does not
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
124 # have an explicit alias.
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
125 levels = name.split(b".")
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
126 if full_pyramid is not None:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
127 if not full_pyramid:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
128 build_pyramid(table, full_pyramid)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
129
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
130 pyramid.clear()
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
131 pyramid.update(full_pyramid.items())
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
132 else:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
133 build_pyramid(table, pyramid)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
134
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
135 subtree = pyramid
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
136 # Find subtree
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
137 for level in levels:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
138 subtree = subtree.get(level)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
139 if subtree is None:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
140 hint = error.getsimilar(list(alias_table) + list(table), name)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
141 hint = error.similarity_hint(hint)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
142
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
143 raise error.InputError(_(b"unknown check %s" % name), hint=hint)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
144
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
145 # Get all checks in that subtree
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
146 if isinstance(subtree, dict):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
147 stack = list(subtree.items())
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
148 while stack:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
149 current_name, entry = stack.pop()
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
150 if isinstance(entry, dict):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
151 stack.extend(entry.items())
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
152 else:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
153 # (qualified_name, func)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
154 checks[entry[0]] = entry[1]
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
155 else:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
156 checks[name] = check
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
157
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
158 return checks
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
159
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
160
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
161 def pass_options(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
162 ui,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
163 checks,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
164 options,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
165 table=None,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
166 alias_table=None,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
167 full_pyramid=None,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
168 ):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
169 """Given a dict of checks (fully qualified name to function), and a list
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
170 of options as given by the user, pass each option down to the right check
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
171 function."""
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
172 ui.debug(b"passing options to check functions\n")
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
173 to_modify = collections.defaultdict(dict)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
174
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
175 if not checks:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
176 raise error.Error(_(b"`checks` required"))
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
177
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
178 for option in sorted(options):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
179 split = option.split(b":")
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
180 hint = _(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
181 b"syntax is 'check:option=value', "
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
182 b"eg. revlogs.changelog:copies=yes"
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
183 )
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
184 option_error = error.InputError(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
185 _(b"invalid option '%s'") % option, hint=hint
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
186 )
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
187 if len(split) != 2:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
188 raise option_error
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
189
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
190 check_name, option_value = split
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
191 if not option_value:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
192 raise option_error
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
193
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
194 split = option_value.split(b"=")
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
195 if len(split) != 2:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
196 raise option_error
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
197
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
198 option_name, value = split
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
199 if not value:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
200 raise option_error
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
201
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
202 path = b"%s:%s" % (check_name, option_name)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
203
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
204 matching_checks = find_checks(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
205 check_name,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
206 table=table,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
207 alias_table=alias_table,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
208 full_pyramid=full_pyramid,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
209 )
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
210 for name in matching_checks:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
211 check = checks.get(name)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
212 if check is None:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
213 msg = _(b"specified option '%s' for unselected check '%s'\n")
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
214 raise error.InputError(msg % (name, option_name))
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
215
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
216 assert hasattr(check, "func") # help Pytype
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
217
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
218 if not hasattr(check.func, "options"):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
219 raise error.InputError(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
220 _(b"check '%s' has no option '%s'") % (name, option_name)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
221 )
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
222
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
223 try:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
224 matching_option = next(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
225 (o for o in check.func.options if o[0] == option_name)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
226 )
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
227 except StopIteration:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
228 raise error.InputError(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
229 _(b"check '%s' has no option '%s'") % (name, option_name)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
230 )
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
231
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
232 # transform the argument from cli string to the expected Python type
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
233 _name, typ, _docstring = matching_option
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
234
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
235 as_typed = None
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
236 if isinstance(typ, bool):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
237 as_bool = stringutil.parsebool(value)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
238 if as_bool is None:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
239 raise error.InputError(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
240 _(b"'%s' is not a boolean ('%s')") % (path, value)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
241 )
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
242 as_typed = as_bool
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
243 elif isinstance(typ, list):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
244 as_list = stringutil.parselist(value)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
245 if as_list is None:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
246 raise error.InputError(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
247 _(b"'%s' is not a list ('%s')") % (path, value)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
248 )
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
249 as_typed = as_list
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
250 else:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
251 raise error.ProgrammingError(b"unsupported type %s", type(typ))
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
252
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
253 if option_name in to_modify[name]:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
254 raise error.InputError(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
255 _(b"duplicated option '%s' for '%s'") % (option_name, name)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
256 )
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
257 else:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
258 assert as_typed is not None
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
259 to_modify[name][option_name] = as_typed
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
260
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
261 # Manage case where a check is set but without command line options
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
262 # it will later be set with default check options values
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
263 for name, f in checks.items():
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
264 if name not in to_modify:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
265 to_modify[name] = {}
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
266
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
267 # Merge default options with command line options
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
268 for check_name, cmd_options in to_modify.items():
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
269 check = checks.get(check_name)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
270 func = checks[check_name]
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
271 merged_options = {}
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
272 # help Pytype
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
273 assert check is not None
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
274 assert check.func is not None
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
275 assert hasattr(check.func, "options")
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
276
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
277 if check.func.options:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
278 # copy the default value in case it's mutable (list, etc.)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
279 merged_options = {
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
280 o[0]: copy.deepcopy(o[1]) for o in check.func.options
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
281 }
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
282 if cmd_options:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
283 for k, v in cmd_options.items():
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
284 merged_options[k] = v
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
285 options = pycompat.strkwargs(merged_options)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
286 checks[check_name] = functools.partial(func, **options)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
287 ui.debug(b"merged options for '%s': '%r'\n" % (check_name, options))
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
288
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
289 return checks
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
290
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
291
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
292 def get_checks(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
293 repo,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
294 ui,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
295 names=None,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
296 options=None,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
297 table=None,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
298 alias_table=None,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
299 full_pyramid=None,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
300 ):
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
301 """Given a list of function names and optionally a list of
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
302 options, return matched checks with merged options (command line options
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
303 values take precedence on default ones)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
304
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
305 It runs find checks, then resolve options and returns a dict of matched
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
306 functions with resolved options.
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
307 """
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
308 funcs = {}
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
309
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
310 if names is None:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
311 names = []
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
312
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
313 if options is None:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
314 options = []
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
315
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
316 # find checks
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
317 for name in names:
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
318 matched = find_checks(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
319 name,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
320 table=table,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
321 alias_table=alias_table,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
322 full_pyramid=full_pyramid,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
323 )
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
324 matched_names = b", ".join(matched)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
325 ui.debug(b"found checks '%s' for name '%s'\n" % (matched_names, name))
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
326 funcs.update(matched)
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
327
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
328 funcs = {n: functools.partial(f, ui, repo) for n, f in funcs.items()}
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
329
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
330 # resolve options
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
331 checks = pass_options(
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
332 ui,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
333 funcs,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
334 options,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
335 table=table,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
336 alias_table=alias_table,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
337 full_pyramid=full_pyramid,
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
338 )
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
339
752c5a5b73c6 admin-command: add verify command
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
340 return checks