changeset 32377:c942c83ac2ec

debugcommands: use temporary dict for its command table Instead, load the table by commands.py so the debug commands should always be populated. The table in debugcommands.py is unnamed so extension authors wouldn't be confused to wrap debugcommands.table in place of commands.table.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 04 May 2017 17:13:12 +0900
parents b16cb0a27377
children 7d0c69505a66
files hgext/largefiles/uisetup.py mercurial/commands.py mercurial/debugcommands.py mercurial/dispatch.py
diffstat 4 files changed, 3 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/uisetup.py	Sun May 14 16:42:16 2017 +0900
+++ b/hgext/largefiles/uisetup.py	Thu May 04 17:13:12 2017 +0900
@@ -21,7 +21,6 @@
     cmdutil,
     commands,
     copies,
-    debugcommands,
     exchange,
     extensions,
     filemerge,
@@ -40,11 +39,6 @@
 )
 
 def uisetup(ui):
-    # TODO: debugcommands should use a separate command table
-    # Side-effect of accessing is debugcommands module is guaranteed to be
-    # imported and commands.table is populated.
-    debugcommands.command
-
     # Disable auto-status for some commands which assume that all
     # files in the result are under Mercurial's control
 
--- a/mercurial/commands.py	Sun May 14 16:42:16 2017 +0900
+++ b/mercurial/commands.py	Thu May 04 17:13:12 2017 +0900
@@ -26,6 +26,7 @@
     changegroup,
     cmdutil,
     copies,
+    debugcommands as debugcommandsmod,
     destutil,
     dirstateguard,
     discovery,
@@ -59,6 +60,7 @@
 release = lockmod.release
 
 table = {}
+table.update(debugcommandsmod.command._table)
 
 command = registrar.command(table)
 
--- a/mercurial/debugcommands.py	Sun May 14 16:42:16 2017 +0900
+++ b/mercurial/debugcommands.py	Thu May 04 17:13:12 2017 +0900
@@ -32,7 +32,6 @@
     changegroup,
     cmdutil,
     color,
-    commands,
     context,
     dagparser,
     dagutil,
@@ -71,9 +70,7 @@
 
 release = lockmod.release
 
-# We reuse the command table from commands because it is easier than
-# teaching dispatch about multiple tables.
-command = registrar.command(commands.table)
+command = registrar.command()
 
 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
 def debugancestor(ui, repo, *args):
--- a/mercurial/dispatch.py	Sun May 14 16:42:16 2017 +0900
+++ b/mercurial/dispatch.py	Thu May 04 17:13:12 2017 +0900
@@ -25,7 +25,6 @@
     cmdutil,
     color,
     commands,
-    debugcommands,
     demandimport,
     encoding,
     error,
@@ -750,10 +749,6 @@
     rpath = _earlygetopt(["-R", "--repository", "--repo"], args)
     path, lui = _getlocal(ui, rpath)
 
-    # Side-effect of accessing is debugcommands module is guaranteed to be
-    # imported and commands.table is populated.
-    debugcommands.command
-
     uis = {ui, lui}
 
     if req.repo: