Patchwork commands: restore compatibility for "^cmd" registration (issue6005)

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 18, 2018, 12:29 p.m.
Message ID <21cf5d2d5b7e2c5264bc.1539865772@mimosa>
Download mbox | patch
Permalink /patch/36131/
State Accepted
Headers show

Comments

Yuya Nishihara - Oct. 18, 2018, 12:29 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.
Boris FELD - Oct. 22, 2018, 1:41 p.m.
This patch looks good!

On 18/10/2018 14:29, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@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")
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

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")