commands: move commands.table to a separate module

Summary:
This allows `commands/__init__.py` and `commands/<command>.py` to both import
the module. So there is no need for `__init__.py` to manually update the
command table.

Reviewed By: kulshrax

Differential Revision: D15640719

fbshipit-source-id: 684983cf91006ec0d504cb01a5f616c0d1f7ac29
This commit is contained in:
Jun Wu 2019-06-07 10:02:04 -07:00 committed by Facebook Github Bot
parent beb78860b1
commit befcda6123
10 changed files with 41 additions and 53 deletions

View File

@ -17,16 +17,7 @@ import subprocess
import sys
import time
from . import (
debug,
debugcheckoutidentifier,
debugmutation,
debugstatus,
debugstrip,
eden,
fs,
uncommit,
)
from . import cmdtable
from .. import (
archival,
bookmarks,
@ -64,30 +55,34 @@ from .. import (
streamclone,
tags as tagsmod,
templatekw,
treestate,
ui as uimod,
util,
)
from ... import hgdemandimport
from ..i18n import _
from ..node import bin, hex, nullid, nullrev, short
with hgdemandimport.disabled():
# Importing these modules have side effect on the command table.
from . import ( # noqa: F401
debug,
debugcheckoutidentifier,
debugmutation,
debugstatus,
debugstrip,
eden,
fs,
uncommit,
)
release = lockmod.release
table = {}
table.update(debug.command._table)
table = cmdtable.table
command = cmdtable.command
command = registrar.command(table)
readonly = registrar.command.readonly
table.update(uncommit.cmdtable)
table.update(debugcheckoutidentifier.command._table)
table.update(debugmutation.command._table)
table.update(debugstatus.command._table)
table.update(debugstrip.command._table)
table.update(eden.command._table)
table.update(fs.command._table)
# common command options
globalopts = [

View File

@ -0,0 +1,12 @@
# Copyright 2019 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from .. import registrar
table = {}
command = registrar.command(table)

View File

@ -53,7 +53,6 @@ from .. import (
progress,
pvec,
pycompat,
registrar,
repair,
revlog,
revset,
@ -73,12 +72,11 @@ from .. import (
)
from ..i18n import _
from ..node import bin, hex, nullhex, nullid, nullrev, short
from .cmdtable import command
release = lockmod.release
command = registrar.command()
try:
xrange(0)
except NameError:

View File

@ -5,10 +5,7 @@
from __future__ import absolute_import
from .. import registrar
command = registrar.command()
from .cmdtable import command
@command("debugcheckoutidentifier", [])

View File

@ -7,11 +7,9 @@
from __future__ import absolute_import
from .. import mutation, node as nodemod, pycompat, registrar, scmutil, util, visibility
from .. import mutation, node as nodemod, pycompat, scmutil, util, visibility
from ..i18n import _
command = registrar.command()
from .cmdtable import command
@command(b"debugmutation", [], _("[REV]"))

View File

@ -3,11 +3,9 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from .. import error, registrar
from .. import error
from ..i18n import _
command = registrar.command()
from .cmdtable import command
@command("debugstatus", [("n", "nonnormal", 0, _("print nonnormalfiltered samples"))])

View File

@ -14,19 +14,17 @@ from .. import (
merge,
node as nodemod,
pycompat,
registrar,
repair,
scmutil,
util,
)
from ..i18n import _
from .cmdtable import command
nullid = nodemod.nullid
release = lockmod.release
command = registrar.command()
def checklocalchanges(repo, force=False, excsuffix=""):
cmdutil.checkunfinished(repo)

View File

@ -13,11 +13,9 @@ import struct
import sys
import time
from .. import error, extensions, hg, pycompat, registrar, scmutil, txnutil, ui, util
from .. import error, extensions, hg, pycompat, scmutil, txnutil, ui, util
from ..i18n import _
command = registrar.command()
from .cmdtable import command
if pycompat.iswindows:

View File

@ -10,11 +10,9 @@ from __future__ import absolute_import
import errno
import subprocess
from .. import cmdutil, error, registrar
from .. import cmdutil, error
from ..i18n import _
command = registrar.command()
from .cmdtable import command
@command("fs", [], subonly=True, norepo=True)

View File

@ -25,17 +25,13 @@ from .. import (
copies,
error,
pycompat,
registrar,
rewriteutil,
scmutil,
treestate,
)
from ..i18n import _
from ..node import nullid
cmdtable = {}
command = registrar.command(cmdtable)
from .cmdtable import command
@command(