[PATCH] commands: restore compatibility for "^cmd" registration (issue6005)

Yuya Nishihara yuya at tcha.org
Thu Oct 18 12:29:32 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1539864862 -32400
#      Thu Oct 18 21:14:22 2018 +0900
# Node ID 21cf5d2d5b7e2c5264bc132285cdd042c21d2b38
# Parent  10e4e6d63c504f1117b0d49160e301d21818515f
commands: restore compatibility for "^cmd" registration (issue6005)

This is done at loading time, where ui is available.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6135,6 +6135,16 @@ def version_(ui, **opts):
 def loadcmdtable(ui, name, cmdtable):
     """Load command functions from specified cmdtable
     """
+    cmdtable = cmdtable.copy()
+    for cmd in list(cmdtable):
+        if not cmd.startswith('^'):
+            continue
+        ui.deprecwarn("old-style command registration '%s' in extension '%s'"
+                      % (cmd, name), '4.8')
+        entry = cmdtable.pop(cmd)
+        entry[0].helpbasic = True
+        cmdtable[cmd[1:]] = entry
+
     overrides = [cmd for cmd in cmdtable if cmd in table]
     if overrides:
         ui.warn(_("extension '%s' overrides commands: %s\n")


More information about the Mercurial-devel mailing list