mercurial/registrar.py
changeset 50989 752c5a5b73c6
parent 50928 d718eddf01d9
child 51297 4d12ffde8377
--- a/mercurial/registrar.py	Wed Sep 13 12:25:51 2023 +0200
+++ b/mercurial/registrar.py	Wed Jan 25 15:34:27 2023 +0100
@@ -6,6 +6,7 @@
 # GNU General Public License version 2 or any later version.
 
 
+from typing import Any, List, Optional, Tuple
 from . import (
     configitems,
     error,
@@ -533,3 +534,30 @@
 
         # actual capabilities, which this internal merge tool has
         func.capabilities = {b"binary": binarycap, b"symlink": symlinkcap}
+
+
+class verify_check(_funcregistrarbase):
+    """Decorator to register a check for admin::verify
+
+    options is a list of (name, default value, help) to be passed to the check
+    """
+
+    def __init__(self, table=None, alias_table=None):
+        super().__init__(table)
+        if alias_table is None:
+            self._alias_table = {}
+        else:
+            self._alias_table = alias_table
+
+    def _extrasetup(
+        self,
+        name,
+        func,
+        alias: Optional[bytes] = None,
+        options: Optional[List[Tuple[bytes, Any, bytes]]] = None,
+    ):
+        func.alias = alias
+        func.options = options
+
+        if alias:
+            self._alias_table[alias] = name