Patchwork [3,of,3] debugcommands: use temporary dict for its command table

login
register
mail settings
Submitter Yuya Nishihara
Date May 20, 2017, 8:40 a.m.
Message ID <e54e0e4af63f49e42002.1495269642@mimosa>
Download mbox | patch
Permalink /patch/20760/
State Accepted
Headers show

Comments

Yuya Nishihara - May 20, 2017, 8:40 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1493885592 -32400
#      Thu May 04 17:13:12 2017 +0900
# Node ID e54e0e4af63f49e42002258958698bc1fb418efb
# Parent  b82cdd2006453757b8b2e782dcf07ca9d34c4f64
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.
Augie Fackler - May 20, 2017, 8:59 p.m.
On Sat, May 20, 2017 at 05:40:42PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1493885592 -32400
> #      Thu May 04 17:13:12 2017 +0900
> # Node ID e54e0e4af63f49e42002258958698bc1fb418efb
> # Parent  b82cdd2006453757b8b2e782dcf07ca9d34c4f64
> debugcommands: use temporary dict for its command table

queued, thanks

Patch

diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -21,7 +21,6 @@  from mercurial import (
     cmdutil,
     commands,
     copies,
-    debugcommands,
     exchange,
     extensions,
     filemerge,
@@ -40,11 +39,6 @@  from . import (
 )
 
 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
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -26,6 +26,7 @@  from . import (
     changegroup,
     cmdutil,
     copies,
+    debugcommands as debugcommandsmod,
     destutil,
     dirstateguard,
     discovery,
@@ -59,6 +60,7 @@  from . import (
 release = lockmod.release
 
 table = {}
+table.update(debugcommandsmod.command._table)
 
 command = registrar.command(table)
 
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -32,7 +32,6 @@  from . import (
     changegroup,
     cmdutil,
     color,
-    commands,
     context,
     dagparser,
     dagutil,
@@ -71,9 +70,7 @@  from . import (
 
 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):
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -25,7 +25,6 @@  from . import (
     cmdutil,
     color,
     commands,
-    debugcommands,
     demandimport,
     encoding,
     error,
@@ -750,10 +749,6 @@  def _dispatch(req):
     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: