[PATCH 1 of 2 RFC] dispatch: remember command table per extension (PoC DO NOT PUSH)

Yuya Nishihara yuya at tcha.org
Thu Feb 22 14:54:46 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1516797703 -32400
#      Wed Jan 24 21:41:43 2018 +0900
# Node ID e2030eaec92b1ed12577cbe48cd0495d106818a9
# Parent  b8d0761a85c7421071750de23228415306852d69
dispatch: remember command table per extension (PoC DO NOT PUSH)

The next patch will make it possible to look up commands shadowed by user
aliases.

This patch shouldn't be published because namespace[] cannot be updated by
extensions.wrapcommand(). That might be okay, but wouldn't be what we want.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -64,10 +64,12 @@ from . import (
 
 release = lockmod.release
 
+# commands table per extension ('' for built-in commands)
+namespace = {'': {}}
+# active commands table (may be updated by dispatcher and extensions)
 table = {}
-table.update(debugcommandsmod.command._table)
-
-command = registrar.command(table)
+
+command = registrar.command()
 readonly = registrar.command.readonly
 
 # common command options
@@ -5606,4 +5608,11 @@ def loadcmdtable(ui, name, cmdtable):
     if overrides:
         ui.warn(_("extension '%s' overrides commands: %s\n")
                 % (name, " ".join(overrides)))
+    namespace[name] = cmdtable
     table.update(cmdtable)
+
+# load built-in commands
+namespace[''].update(debugcommandsmod.command._table)
+namespace[''].update(command._table)
+table.update(debugcommandsmod.command._table)
+table.update(command._table)


More information about the Mercurial-devel mailing list