Commit 350b90f9 authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

registrar: move cmdutil.command to registrar module (API)

cmdutil.command wasn't a member of the registrar framework only for a
historical reason. Let's make that happen. This patch keeps cmdutil.command
as an alias for extension compatibility.
parent ff874d34c856
......@@ -6,12 +6,12 @@ import code
import mercurial
import sys
from mercurial import (
cmdutil,
demandimport,
registrar,
)
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
def pdb(ui, repo, msg, **opts):
objects = {
......
......@@ -48,6 +48,11 @@ try:
from mercurial import obsolete # since 2.3 (or ad0d6c2b3279)
except ImportError:
pass
try:
from mercurial import registrar # since 3.7 (or 37d50250b696)
dir(registrar) # forcibly load it
except ImportError:
registrar = None
try:
from mercurial import repoview # since 2.5 (or 3a6ddacb7198)
except ImportError:
......@@ -101,7 +106,9 @@ cmdtable = {}
def parsealiases(cmd):
return cmd.lstrip("^").split("|")
if safehasattr(cmdutil, 'command'):
if safehasattr(registrar, 'command'):
command = registrar.command(cmdtable)
elif safehasattr(cmdutil, 'command'):
import inspect
command = cmdutil.command(cmdtable)
if 'norepo' not in inspect.getargspec(command)[0]:
......
......@@ -53,11 +53,11 @@ from mercurial.node import (
short,
)
from mercurial import (
cmdutil,
context,
error,
hg,
patch,
registrar,
scmutil,
util,
)
......@@ -69,7 +69,7 @@ from mercurial import (
testedwith = 'ships-with-hg-core'
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
newfile = {'new fi', 'rename', 'copy f', 'copy t'}
......
......@@ -44,13 +44,13 @@ from mercurial.i18n import _
from mercurial.node import hex
from mercurial import (
cmdutil,
registrar,
ui as uimod,
util,
)
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
......@@ -31,17 +31,17 @@ from mercurial.i18n import _
from mercurial.node import short
from mercurial import (
cmdutil,
error,
filelog,
lock as lockmod,
registrar,
revlog,
scmutil,
util,
)
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
......@@ -20,12 +20,13 @@ from mercurial.i18n import _
from mercurial import (
cmdutil,
commands,
registrar,
)
templateopts = commands.templateopts
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
......@@ -20,12 +20,13 @@ from mercurial import (
commands,
encoding,
patch,
registrar,
scmutil,
util,
)
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
......@@ -11,7 +11,6 @@ from __future__ import absolute_import
from mercurial.i18n import _
from mercurial import (
cmdutil,
registrar,
)
......@@ -22,7 +21,7 @@ from . import (
)
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
......@@ -78,12 +78,13 @@ from mercurial import (
error,
filemerge,
pycompat,
registrar,
scmutil,
util,
)
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
......@@ -20,12 +20,13 @@ from mercurial import (
exchange,
hg,
lock,
registrar,
util,
)
release = lock.release
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
......@@ -19,11 +19,12 @@ from mercurial import (
match,
node as hgnode,
pycompat,
registrar,
util,
)
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
......@@ -19,12 +19,12 @@ from __future__ import absolute_import
from mercurial.i18n import _
from mercurial import (
cmdutil,
commands,
registrar,
)
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
......@@ -45,15 +45,15 @@ from mercurial.node import (
short,
)
from mercurial import (
cmdutil,
commands,
obsolete,
patch,
registrar,
scmutil,
)
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
......@@ -201,6 +201,7 @@ from mercurial import (
mergeutil,
node,
obsolete,
registrar,
repair,
scmutil,
util,
......@@ -209,7 +210,7 @@ from mercurial import (
pickle = util.pickle
release = lock.release
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
......
......@@ -31,13 +31,14 @@ from mercurial import (
localrepo,
lock,
node,
registrar,
util,
)
from . import share
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
......
......@@ -111,7 +111,7 @@ from mercurial import (
)
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
......@@ -25,6 +25,7 @@ from mercurial import (
lock,
match as matchmod,
node,
registrar,
scmutil,
util,
)
......@@ -44,7 +45,7 @@ release = lock.release
# -- Commands ----------------------------------------------------------
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
@command('lfconvert',
[('s', 'size', '',
......
......@@ -101,7 +101,7 @@ release = lockmod.release
seriesopts = [('s', 'summary', None, _('print first line of patch header'))]
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
......@@ -89,6 +89,7 @@ from mercurial import (
mail,
node as nodemod,
patch,
registrar,
scmutil,
templater,
util,
......@@ -96,7 +97,7 @@ from mercurial import (
stringio = util.stringio
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
......@@ -29,15 +29,15 @@ import os
from mercurial.i18n import _
from mercurial import (
cmdutil,
commands,
error,
registrar,
scmutil,
util,
)
cmdtable = {}
command = cmdutil.command(cmdtable)
command = registrar.command(cmdtable)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment