##// END OF EJS Templates
registrar: move cmdutil.command to registrar module (API)...
Yuya Nishihara -
r32337:46ba2cdd default
parent child Browse files
Show More
@@ -6,12 +6,12 b' import code'
6 6 import mercurial
7 7 import sys
8 8 from mercurial import (
9 cmdutil,
10 9 demandimport,
10 registrar,
11 11 )
12 12
13 13 cmdtable = {}
14 command = cmdutil.command(cmdtable)
14 command = registrar.command(cmdtable)
15 15
16 16 def pdb(ui, repo, msg, **opts):
17 17 objects = {
@@ -49,6 +49,11 b' try:'
49 49 except ImportError:
50 50 pass
51 51 try:
52 from mercurial import registrar # since 3.7 (or 37d50250b696)
53 dir(registrar) # forcibly load it
54 except ImportError:
55 registrar = None
56 try:
52 57 from mercurial import repoview # since 2.5 (or 3a6ddacb7198)
53 58 except ImportError:
54 59 pass
@@ -101,7 +106,9 b' cmdtable = {}'
101 106 def parsealiases(cmd):
102 107 return cmd.lstrip("^").split("|")
103 108
104 if safehasattr(cmdutil, 'command'):
109 if safehasattr(registrar, 'command'):
110 command = registrar.command(cmdtable)
111 elif safehasattr(cmdutil, 'command'):
105 112 import inspect
106 113 command = cmdutil.command(cmdtable)
107 114 if 'norepo' not in inspect.getargspec(command)[0]:
@@ -53,11 +53,11 b' from mercurial.node import ('
53 53 short,
54 54 )
55 55 from mercurial import (
56 cmdutil,
57 56 context,
58 57 error,
59 58 hg,
60 59 patch,
60 registrar,
61 61 scmutil,
62 62 util,
63 63 )
@@ -69,7 +69,7 b' from mercurial import ('
69 69 testedwith = 'ships-with-hg-core'
70 70
71 71 cmdtable = {}
72 command = cmdutil.command(cmdtable)
72 command = registrar.command(cmdtable)
73 73
74 74 newfile = {'new fi', 'rename', 'copy f', 'copy t'}
75 75
@@ -44,13 +44,13 b' from mercurial.i18n import _'
44 44 from mercurial.node import hex
45 45
46 46 from mercurial import (
47 cmdutil,
47 registrar,
48 48 ui as uimod,
49 49 util,
50 50 )
51 51
52 52 cmdtable = {}
53 command = cmdutil.command(cmdtable)
53 command = registrar.command(cmdtable)
54 54 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
55 55 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
56 56 # be specifying the version(s) of Mercurial they are tested with, or
@@ -31,17 +31,17 b' from mercurial.i18n import _'
31 31 from mercurial.node import short
32 32
33 33 from mercurial import (
34 cmdutil,
35 34 error,
36 35 filelog,
37 36 lock as lockmod,
37 registrar,
38 38 revlog,
39 39 scmutil,
40 40 util,
41 41 )
42 42
43 43 cmdtable = {}
44 command = cmdutil.command(cmdtable)
44 command = registrar.command(cmdtable)
45 45 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
46 46 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
47 47 # be specifying the version(s) of Mercurial they are tested with, or
@@ -20,12 +20,13 b' from mercurial.i18n import _'
20 20 from mercurial import (
21 21 cmdutil,
22 22 commands,
23 registrar,
23 24 )
24 25
25 26 templateopts = commands.templateopts
26 27
27 28 cmdtable = {}
28 command = cmdutil.command(cmdtable)
29 command = registrar.command(cmdtable)
29 30 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
30 31 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
31 32 # be specifying the version(s) of Mercurial they are tested with, or
@@ -20,12 +20,13 b' from mercurial import ('
20 20 commands,
21 21 encoding,
22 22 patch,
23 registrar,
23 24 scmutil,
24 25 util,
25 26 )
26 27
27 28 cmdtable = {}
28 command = cmdutil.command(cmdtable)
29 command = registrar.command(cmdtable)
29 30 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
30 31 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
31 32 # be specifying the version(s) of Mercurial they are tested with, or
@@ -11,7 +11,6 b' from __future__ import absolute_import'
11 11
12 12 from mercurial.i18n import _
13 13 from mercurial import (
14 cmdutil,
15 14 registrar,
16 15 )
17 16
@@ -22,7 +21,7 b' from . import ('
22 21 )
23 22
24 23 cmdtable = {}
25 command = cmdutil.command(cmdtable)
24 command = registrar.command(cmdtable)
26 25 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
27 26 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
28 27 # be specifying the version(s) of Mercurial they are tested with, or
@@ -78,12 +78,13 b' from mercurial import ('
78 78 error,
79 79 filemerge,
80 80 pycompat,
81 registrar,
81 82 scmutil,
82 83 util,
83 84 )
84 85
85 86 cmdtable = {}
86 command = cmdutil.command(cmdtable)
87 command = registrar.command(cmdtable)
87 88 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
88 89 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
89 90 # be specifying the version(s) of Mercurial they are tested with, or
@@ -20,12 +20,13 b' from mercurial import ('
20 20 exchange,
21 21 hg,
22 22 lock,
23 registrar,
23 24 util,
24 25 )
25 26
26 27 release = lock.release
27 28 cmdtable = {}
28 command = cmdutil.command(cmdtable)
29 command = registrar.command(cmdtable)
29 30 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
30 31 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
31 32 # be specifying the version(s) of Mercurial they are tested with, or
@@ -19,11 +19,12 b' from mercurial import ('
19 19 match,
20 20 node as hgnode,
21 21 pycompat,
22 registrar,
22 23 util,
23 24 )
24 25
25 26 cmdtable = {}
26 command = cmdutil.command(cmdtable)
27 command = registrar.command(cmdtable)
27 28 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
28 29 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
29 30 # be specifying the version(s) of Mercurial they are tested with, or
@@ -19,12 +19,12 b' from __future__ import absolute_import'
19 19
20 20 from mercurial.i18n import _
21 21 from mercurial import (
22 cmdutil,
23 22 commands,
23 registrar,
24 24 )
25 25
26 26 cmdtable = {}
27 command = cmdutil.command(cmdtable)
27 command = registrar.command(cmdtable)
28 28 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
29 29 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
30 30 # be specifying the version(s) of Mercurial they are tested with, or
@@ -45,15 +45,15 b' from mercurial.node import ('
45 45 short,
46 46 )
47 47 from mercurial import (
48 cmdutil,
49 48 commands,
50 49 obsolete,
51 50 patch,
51 registrar,
52 52 scmutil,
53 53 )
54 54
55 55 cmdtable = {}
56 command = cmdutil.command(cmdtable)
56 command = registrar.command(cmdtable)
57 57 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
58 58 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
59 59 # be specifying the version(s) of Mercurial they are tested with, or
@@ -201,6 +201,7 b' from mercurial import ('
201 201 mergeutil,
202 202 node,
203 203 obsolete,
204 registrar,
204 205 repair,
205 206 scmutil,
206 207 util,
@@ -209,7 +210,7 b' from mercurial import ('
209 210 pickle = util.pickle
210 211 release = lock.release
211 212 cmdtable = {}
212 command = cmdutil.command(cmdtable)
213 command = registrar.command(cmdtable)
213 214
214 215 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
215 216 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
@@ -31,13 +31,14 b' from mercurial import ('
31 31 localrepo,
32 32 lock,
33 33 node,
34 registrar,
34 35 util,
35 36 )
36 37
37 38 from . import share
38 39
39 40 cmdtable = {}
40 command = cmdutil.command(cmdtable)
41 command = registrar.command(cmdtable)
41 42
42 43 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
43 44 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
@@ -111,7 +111,7 b' from mercurial import ('
111 111 )
112 112
113 113 cmdtable = {}
114 command = cmdutil.command(cmdtable)
114 command = registrar.command(cmdtable)
115 115 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
116 116 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
117 117 # be specifying the version(s) of Mercurial they are tested with, or
@@ -25,6 +25,7 b' from mercurial import ('
25 25 lock,
26 26 match as matchmod,
27 27 node,
28 registrar,
28 29 scmutil,
29 30 util,
30 31 )
@@ -44,7 +45,7 b' release = lock.release'
44 45 # -- Commands ----------------------------------------------------------
45 46
46 47 cmdtable = {}
47 command = cmdutil.command(cmdtable)
48 command = registrar.command(cmdtable)
48 49
49 50 @command('lfconvert',
50 51 [('s', 'size', '',
@@ -101,7 +101,7 b' release = lockmod.release'
101 101 seriesopts = [('s', 'summary', None, _('print first line of patch header'))]
102 102
103 103 cmdtable = {}
104 command = cmdutil.command(cmdtable)
104 command = registrar.command(cmdtable)
105 105 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
106 106 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
107 107 # be specifying the version(s) of Mercurial they are tested with, or
@@ -89,6 +89,7 b' from mercurial import ('
89 89 mail,
90 90 node as nodemod,
91 91 patch,
92 registrar,
92 93 scmutil,
93 94 templater,
94 95 util,
@@ -96,7 +97,7 b' from mercurial import ('
96 97 stringio = util.stringio
97 98
98 99 cmdtable = {}
99 command = cmdutil.command(cmdtable)
100 command = registrar.command(cmdtable)
100 101 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
101 102 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
102 103 # be specifying the version(s) of Mercurial they are tested with, or
@@ -29,15 +29,15 b' import os'
29 29
30 30 from mercurial.i18n import _
31 31 from mercurial import (
32 cmdutil,
33 32 commands,
34 33 error,
34 registrar,
35 35 scmutil,
36 36 util,
37 37 )
38 38
39 39 cmdtable = {}
40 command = cmdutil.command(cmdtable)
40 command = registrar.command(cmdtable)
41 41 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
42 42 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
43 43 # be specifying the version(s) of Mercurial they are tested with, or
@@ -68,7 +68,7 b' revpruned = -5'
68 68 revskipped = (revignored, revprecursor, revpruned)
69 69
70 70 cmdtable = {}
71 command = cmdutil.command(cmdtable)
71 command = registrar.command(cmdtable)
72 72 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
73 73 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
74 74 # be specifying the version(s) of Mercurial they are tested with, or
@@ -18,10 +18,11 b' from mercurial import ('
18 18 commands,
19 19 error,
20 20 extensions,
21 registrar,
21 22 )
22 23
23 24 cmdtable = {}
24 command = cmdutil.command(cmdtable)
25 command = registrar.command(cmdtable)
25 26 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
26 27 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
27 28 # be specifying the version(s) of Mercurial they are tested with, or
@@ -13,14 +13,14 b' import stat'
13 13
14 14 from mercurial.i18n import _
15 15 from mercurial import (
16 cmdutil,
17 16 error,
18 17 hg,
18 registrar,
19 19 util,
20 20 )
21 21
22 22 cmdtable = {}
23 command = cmdutil.command(cmdtable)
23 command = registrar.command(cmdtable)
24 24 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
25 25 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
26 26 # be specifying the version(s) of Mercurial they are tested with, or
@@ -46,17 +46,17 b' import re'
46 46
47 47 from mercurial.i18n import _
48 48 from mercurial import (
49 cmdutil,
50 49 error,
51 50 extensions,
52 51 hg,
53 52 pycompat,
53 registrar,
54 54 templater,
55 55 util,
56 56 )
57 57
58 58 cmdtable = {}
59 command = cmdutil.command(cmdtable)
59 command = registrar.command(cmdtable)
60 60 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
61 61 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
62 62 # be specifying the version(s) of Mercurial they are tested with, or
@@ -43,11 +43,11 b' import errno'
43 43 from mercurial.i18n import _
44 44 from mercurial import (
45 45 bookmarks,
46 cmdutil,
47 46 commands,
48 47 error,
49 48 extensions,
50 49 hg,
50 registrar,
51 51 txnutil,
52 52 util,
53 53 )
@@ -56,7 +56,7 b' repository = hg.repository'
56 56 parseurl = hg.parseurl
57 57
58 58 cmdtable = {}
59 command = cmdutil.command(cmdtable)
59 command = registrar.command(cmdtable)
60 60 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
61 61 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
62 62 # be specifying the version(s) of Mercurial they are tested with, or
@@ -43,6 +43,7 b' from mercurial import ('
43 43 node as nodemod,
44 44 patch,
45 45 phases,
46 registrar,
46 47 repair,
47 48 scmutil,
48 49 templatefilters,
@@ -55,7 +56,7 b' from . import ('
55 56 )
56 57
57 58 cmdtable = {}
58 command = cmdutil.command(cmdtable)
59 command = registrar.command(cmdtable)
59 60 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
60 61 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
61 62 # be specifying the version(s) of Mercurial they are tested with, or
@@ -34,7 +34,7 b' from mercurial import ('
34 34 testedwith = 'ships-with-hg-core'
35 35
36 36 cmdtable = {}
37 command = cmdutil.command(cmdtable)
37 command = registrar.command(cmdtable)
38 38 revsetpredicate = registrar.revsetpredicate()
39 39
40 40 class showcmdfunc(registrar._funcregistrarbase):
@@ -14,6 +14,7 b' from mercurial import ('
14 14 lock as lockmod,
15 15 merge,
16 16 node as nodemod,
17 registrar,
17 18 repair,
18 19 scmutil,
19 20 util,
@@ -22,7 +23,7 b' nullid = nodemod.nullid'
22 23 release = lockmod.release
23 24
24 25 cmdtable = {}
25 command = cmdutil.command(cmdtable)
26 command = registrar.command(cmdtable)
26 27 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
27 28 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
28 29 # be specifying the version(s) of Mercurial they are tested with, or
@@ -42,7 +42,7 b' class TransplantError(error.Abort):'
42 42 pass
43 43
44 44 cmdtable = {}
45 command = cmdutil.command(cmdtable)
45 command = registrar.command(cmdtable)
46 46 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
47 47 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
48 48 # be specifying the version(s) of Mercurial they are tested with, or
@@ -38,6 +38,7 b' from . import ('
38 38 pathutil,
39 39 phases,
40 40 pycompat,
41 registrar,
41 42 repair,
42 43 revlog,
43 44 revset,
@@ -3334,50 +3335,7 b' def _performrevert(repo, parents, ctx, a'
3334 3335 if f in copied:
3335 3336 repo.dirstate.copy(copied[f], f)
3336 3337
3337 def command(table):
3338 """Returns a function object to be used as a decorator for making commands.
3339
3340 This function receives a command table as its argument. The table should
3341 be a dict.
3342
3343 The returned function can be used as a decorator for adding commands
3344 to that command table. This function accepts multiple arguments to define
3345 a command.
3346
3347 The first argument is the command name.
3348
3349 The options argument is an iterable of tuples defining command arguments.
3350 See ``mercurial.fancyopts.fancyopts()`` for the format of each tuple.
3351
3352 The synopsis argument defines a short, one line summary of how to use the
3353 command. This shows up in the help output.
3354
3355 The norepo argument defines whether the command does not require a
3356 local repository. Most commands operate against a repository, thus the
3357 default is False.
3358
3359 The optionalrepo argument defines whether the command optionally requires
3360 a local repository.
3361
3362 The inferrepo argument defines whether to try to find a repository from the
3363 command line arguments. If True, arguments will be examined for potential
3364 repository locations. See ``findrepo()``. If a repository is found, it
3365 will be used.
3366 """
3367 def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False,
3368 inferrepo=False):
3369 def decorator(func):
3370 func.norepo = norepo
3371 func.optionalrepo = optionalrepo
3372 func.inferrepo = inferrepo
3373 if synopsis:
3374 table[name] = func, list(options), synopsis
3375 else:
3376 table[name] = func, list(options)
3377 return func
3378 return decorator
3379
3380 return cmd
3338 command = registrar.command
3381 3339
3382 3340 # a list of (ui, repo, otherpeer, opts, missing) functions called by
3383 3341 # commands.outgoing. "missing" is "missing" of the result of
@@ -44,6 +44,7 b' from . import ('
44 44 phases,
45 45 pycompat,
46 46 rcutil,
47 registrar,
47 48 revsetlang,
48 49 scmutil,
49 50 server,
@@ -59,7 +60,7 b' release = lockmod.release'
59 60
60 61 table = {}
61 62
62 command = cmdutil.command(table)
63 command = registrar.command(table)
63 64
64 65 # label constants
65 66 # until 3.5, bookmarks.current was the advertised name, not
@@ -51,6 +51,7 b' from . import ('
51 51 policy,
52 52 pvec,
53 53 pycompat,
54 registrar,
54 55 repair,
55 56 revlog,
56 57 revset,
@@ -72,7 +73,7 b' release = lockmod.release'
72 73
73 74 # We reuse the command table from commands because it is easier than
74 75 # teaching dispatch about multiple tables.
75 command = cmdutil.command(commands.table)
76 command = registrar.command(commands.table)
76 77
77 78 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
78 79 def debugancestor(ui, repo, *args):
@@ -96,6 +96,51 b' class _funcregistrarbase(object):'
96 96 """
97 97 pass
98 98
99 def command(table):
100 """Returns a function object to be used as a decorator for making commands.
101
102 This function receives a command table as its argument. The table should
103 be a dict.
104
105 The returned function can be used as a decorator for adding commands
106 to that command table. This function accepts multiple arguments to define
107 a command.
108
109 The first argument is the command name.
110
111 The options argument is an iterable of tuples defining command arguments.
112 See ``mercurial.fancyopts.fancyopts()`` for the format of each tuple.
113
114 The synopsis argument defines a short, one line summary of how to use the
115 command. This shows up in the help output.
116
117 The norepo argument defines whether the command does not require a
118 local repository. Most commands operate against a repository, thus the
119 default is False.
120
121 The optionalrepo argument defines whether the command optionally requires
122 a local repository.
123
124 The inferrepo argument defines whether to try to find a repository from the
125 command line arguments. If True, arguments will be examined for potential
126 repository locations. See ``findrepo()``. If a repository is found, it
127 will be used.
128 """
129 def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False,
130 inferrepo=False):
131 def decorator(func):
132 func.norepo = norepo
133 func.optionalrepo = optionalrepo
134 func.inferrepo = inferrepo
135 if synopsis:
136 table[name] = func, list(options), synopsis
137 else:
138 table[name] = func, list(options)
139 return func
140 return decorator
141
142 return cmd
143
99 144 class revsetpredicate(_funcregistrarbase):
100 145 """Decorator to register revset predicate
101 146
@@ -3,14 +3,14 b''
3 3 from __future__ import absolute_import
4 4
5 5 from mercurial import (
6 cmdutil,
7 6 error,
8 7 patch,
8 registrar,
9 9 scmutil,
10 10 )
11 11
12 12 cmdtable = {}
13 command = cmdutil.command(cmdtable)
13 command = registrar.command(cmdtable)
14 14
15 15 @command('autodiff',
16 16 [('', 'git', '', 'git upgrade mode (yes/no/auto/warn/abort)')],
@@ -80,16 +80,16 b' import itertools'
80 80
81 81 from mercurial.i18n import _
82 82 from mercurial import (
83 cmdutil,
84 83 context,
85 84 error,
86 85 node,
86 registrar,
87 87 scmutil,
88 88 tags as tagsmod,
89 89 )
90 90
91 91 cmdtable = {}
92 command = cmdutil.command(cmdtable)
92 command = registrar.command(cmdtable)
93 93
94 94 _pipechars = '\\/+-|'
95 95 _nonpipechars = ''.join(chr(i) for i in xrange(33, 127)
@@ -5,12 +5,12 b''
5 5 from __future__ import absolute_import
6 6
7 7 from mercurial import (
8 cmdutil,
9 8 merge,
9 registrar,
10 10 )
11 11
12 12 cmdtable = {}
13 command = cmdutil.command(cmdtable)
13 command = registrar.command(cmdtable)
14 14
15 15 @command('fakemergerecord',
16 16 [('X', 'mandatory', None, 'add a fake mandatory record'),
@@ -62,9 +62,9 b' show traceback'
62 62 names of extensions failed to load can be accessed via extensions.notloaded()
63 63
64 64 $ cat <<EOF > showbadexts.py
65 > from mercurial import cmdutil, commands, extensions
65 > from mercurial import commands, extensions, registrar
66 66 > cmdtable = {}
67 > command = cmdutil.command(cmdtable)
67 > command = registrar.command(cmdtable)
68 68 > @command('showbadexts', norepo=True)
69 69 > def showbadexts(ui, *pats, **opts):
70 70 > ui.write('BADEXTS: %s\n' % ' '.join(sorted(extensions.notloaded())))
@@ -14,7 +14,6 b' Create an extension to test bundle2 API'
14 14 > """
15 15 >
16 16 > import sys, os, gc
17 > from mercurial import cmdutil
18 17 > from mercurial import util
19 18 > from mercurial import bundle2
20 19 > from mercurial import scmutil
@@ -22,6 +21,7 b' Create an extension to test bundle2 API'
22 21 > from mercurial import changegroup
23 22 > from mercurial import error
24 23 > from mercurial import obsolete
24 > from mercurial import registrar
25 25 >
26 26 >
27 27 > try:
@@ -33,7 +33,7 b' Create an extension to test bundle2 API'
33 33 > pass
34 34 >
35 35 > cmdtable = {}
36 > command = cmdutil.command(cmdtable)
36 > command = registrar.command(cmdtable)
37 37 >
38 38 > ELEPHANTSSONG = """Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
39 39 > Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
@@ -105,9 +105,9 b' pager should be enabled if the attached '
105 105 chg waits for pager if runcommand raises
106 106
107 107 $ cat > $TESTTMP/crash.py <<EOF
108 > from mercurial import cmdutil
108 > from mercurial import registrar
109 109 > cmdtable = {}
110 > command = cmdutil.command(cmdtable)
110 > command = registrar.command(cmdtable)
111 111 > @command('crash')
112 112 > def pagercrash(ui, repo, *pats, **opts):
113 113 > ui.write('going to crash\n')
@@ -579,9 +579,9 b' changelog and manifest would have invali'
579 579
580 580 $ cat <<EOF > dbgui.py
581 581 > import os, sys
582 > from mercurial import cmdutil, commands
582 > from mercurial import commands, registrar
583 583 > cmdtable = {}
584 > command = cmdutil.command(cmdtable)
584 > command = registrar.command(cmdtable)
585 585 > @command("debuggetpass", norepo=True)
586 586 > def debuggetpass(ui):
587 587 > ui.write("%s\\n" % ui.getpass())
@@ -3,10 +3,10 b''
3 3 > """A small extension that tests our developer warnings
4 4 > """
5 5 >
6 > from mercurial import cmdutil, repair, util
6 > from mercurial import registrar, repair, util
7 7 >
8 8 > cmdtable = {}
9 > command = cmdutil.command(cmdtable)
9 > command = registrar.command(cmdtable)
10 10 >
11 11 > @command('buggylocking', [], '')
12 12 > def buggylocking(ui, repo):
@@ -16,9 +16,9 b' Test alignment of multibyte characters'
16 16 > f = file('l', 'w'); f.write(l); f.close()
17 17 > # instant extension to show list of options
18 18 > f = file('showoptlist.py', 'w'); f.write("""# encoding: utf-8
19 > from mercurial import cmdutil
19 > from mercurial import registrar
20 20 > cmdtable = {}
21 > command = cmdutil.command(cmdtable)
21 > command = registrar.command(cmdtable)
22 22 >
23 23 > @command('showoptlist',
24 24 > [('s', 'opt1', '', 'short width' + ' %(s)s' * 8, '%(s)s'),
@@ -6,10 +6,10 b' Test text wrapping for multibyte charact'
6 6 define commands to display help text
7 7
8 8 $ cat << EOF > show.py
9 > from mercurial import cmdutil
9 > from mercurial import registrar
10 10 >
11 11 > cmdtable = {}
12 > command = cmdutil.command(cmdtable)
12 > command = registrar.command(cmdtable)
13 13 >
14 14 > # Japanese full-width characters:
15 15 > @command('show_full_ja', [], '')
@@ -2,9 +2,9 b' Test basic extension support'
2 2
3 3 $ cat > foobar.py <<EOF
4 4 > import os
5 > from mercurial import cmdutil, commands
5 > from mercurial import commands, registrar
6 6 > cmdtable = {}
7 > command = cmdutil.command(cmdtable)
7 > command = registrar.command(cmdtable)
8 8 > def uisetup(ui):
9 9 > ui.write("uisetup called\\n")
10 10 > ui.flush()
@@ -380,9 +380,9 b' Setup main procedure of extension.'
380 380
381 381 $ cat > $TESTTMP/absextroot/__init__.py <<EOF
382 382 > from __future__ import absolute_import
383 > from mercurial import cmdutil
383 > from mercurial import registrar
384 384 > cmdtable = {}
385 > command = cmdutil.command(cmdtable)
385 > command = registrar.command(cmdtable)
386 386 >
387 387 > # "absolute" and "relative" shouldn't be imported before actual
388 388 > # command execution, because (1) they import same modules, and (2)
@@ -444,9 +444,9 b' See also issue5208 for detail about exam'
444 444 > EOF
445 445
446 446 $ cat > $TESTTMP/checkrelativity.py <<EOF
447 > from mercurial import cmdutil
447 > from mercurial import registrar
448 448 > cmdtable = {}
449 > command = cmdutil.command(cmdtable)
449 > command = registrar.command(cmdtable)
450 450 >
451 451 > # demand import avoids failure of importing notexist here
452 452 > import extlibroot.lsub1.lsub2.notexist
@@ -487,9 +487,9 b' hide outer repo'
487 487 $ cat > debugextension.py <<EOF
488 488 > '''only debugcommands
489 489 > '''
490 > from mercurial import cmdutil
490 > from mercurial import registrar
491 491 > cmdtable = {}
492 > command = cmdutil.command(cmdtable)
492 > command = registrar.command(cmdtable)
493 493 > @command('debugfoobar', [], 'hg debugfoobar')
494 494 > def debugfoobar(ui, repo, *args, **opts):
495 495 > "yet another debug command"
@@ -726,9 +726,9 b' Extension module help vs command help:'
726 726 Test help topic with same name as extension
727 727
728 728 $ cat > multirevs.py <<EOF
729 > from mercurial import cmdutil, commands
729 > from mercurial import commands, registrar
730 730 > cmdtable = {}
731 > command = cmdutil.command(cmdtable)
731 > command = registrar.command(cmdtable)
732 732 > """multirevs extension
733 733 > Big multi-line module docstring."""
734 734 > @command('multirevs', [], 'ARG', norepo=True)
@@ -803,9 +803,9 b' along with extension help itself'
803 803 > This is an awesome 'dodo' extension. It does nothing and
804 804 > writes 'Foo foo'
805 805 > """
806 > from mercurial import cmdutil, commands
806 > from mercurial import commands, registrar
807 807 > cmdtable = {}
808 > command = cmdutil.command(cmdtable)
808 > command = registrar.command(cmdtable)
809 809 > @command('dodo', [], 'hg dodo')
810 810 > def dodo(ui, *args, **kwargs):
811 811 > """Does nothing"""
@@ -914,9 +914,9 b' along with extension help'
914 914 > This is an awesome 'dudu' extension. It does something and
915 915 > also writes 'Beep beep'
916 916 > """
917 > from mercurial import cmdutil, commands
917 > from mercurial import commands, registrar
918 918 > cmdtable = {}
919 > command = cmdutil.command(cmdtable)
919 > command = registrar.command(cmdtable)
920 920 > @command('something', [], 'hg something')
921 921 > def something(ui, *args, **kwargs):
922 922 > """Does something"""
@@ -1157,9 +1157,9 b' Broken disabled extension and command:'
1157 1157 [255]
1158 1158
1159 1159 $ cat > throw.py <<EOF
1160 > from mercurial import cmdutil, commands, util
1160 > from mercurial import commands, registrar, util
1161 1161 > cmdtable = {}
1162 > command = cmdutil.command(cmdtable)
1162 > command = registrar.command(cmdtable)
1163 1163 > class Bogon(Exception): pass
1164 1164 > @command('throw', [], 'hg throw', norepo=True)
1165 1165 > def throw(ui, **opts):
@@ -680,10 +680,10 b' this is a section and erroring out weird'
680 680
681 681 $ cat > helpext.py <<EOF
682 682 > import os
683 > from mercurial import cmdutil, commands
683 > from mercurial import commands, registrar
684 684 >
685 685 > cmdtable = {}
686 > command = cmdutil.command(cmdtable)
686 > command = registrar.command(cmdtable)
687 687 >
688 688 > @command('nohelp',
689 689 > [('', 'longdesc', 3, 'x'*90),
@@ -14,10 +14,10 b' Prepare'
14 14 Test that raising an exception in the release function doesn't cause the lock to choke
15 15
16 16 $ cat > testlock.py << EOF
17 > from mercurial import cmdutil, error, error
17 > from mercurial import error, registrar
18 18 >
19 19 > cmdtable = {}
20 > command = cmdutil.command(cmdtable)
20 > command = registrar.command(cmdtable)
21 21 >
22 22 > def acquiretestlock(repo, releaseexc):
23 23 > def unlock():
@@ -6,10 +6,10 b' Test if logtoprocess correctly captures '
6 6
7 7 $ hg init
8 8 $ cat > $TESTTMP/foocommand.py << EOF
9 > from mercurial import cmdutil
9 > from mercurial import registrar
10 10 > from time import sleep
11 11 > cmdtable = {}
12 > command = cmdutil.command(cmdtable)
12 > command = registrar.command(cmdtable)
13 13 > @command('foo', [])
14 14 > def foo(ui, repo):
15 15 > ui.log('foo', 'a message: %(bar)s\n', bar='spam')
@@ -1065,11 +1065,11 b' Test issue 4506'
1065 1065 Test heads computation on pending index changes with obsolescence markers
1066 1066 $ cd ..
1067 1067 $ cat >$TESTTMP/test_extension.py << EOF
1068 > from mercurial import cmdutil
1068 > from mercurial import cmdutil, registrar
1069 1069 > from mercurial.i18n import _
1070 1070 >
1071 1071 > cmdtable = {}
1072 > command = cmdutil.command(cmdtable)
1072 > command = registrar.command(cmdtable)
1073 1073 > @command("amendtransient",[], _('hg amendtransient [rev]'))
1074 1074 > def amend(ui, repo, *pats, **opts):
1075 1075 > def commitfunc(ui, repo, message, match, opts):
@@ -214,9 +214,9 b' pager is globally set to off using a fla'
214 214 Pager should not override the exit code of other commands
215 215
216 216 $ cat >> $TESTTMP/fortytwo.py <<'EOF'
217 > from mercurial import cmdutil, commands
217 > from mercurial import registrar, commands
218 218 > cmdtable = {}
219 > command = cmdutil.command(cmdtable)
219 > command = registrar.command(cmdtable)
220 220 > @command('fortytwo', [], 'fortytwo', norepo=True)
221 221 > def fortytwo(ui, *opts):
222 222 > ui.write('42\n')
@@ -223,9 +223,9 b' pager is globally set to off using a fla'
223 223 Pager should not override the exit code of other commands
224 224
225 225 $ cat >> $TESTTMP/fortytwo.py <<'EOF'
226 > from mercurial import cmdutil, commands
226 > from mercurial import commands, registrar
227 227 > cmdtable = {}
228 > command = cmdutil.command(cmdtable)
228 > command = registrar.command(cmdtable)
229 229 > @command('fortytwo', [], 'fortytwo', norepo=True)
230 230 > def fortytwo(ui, *opts):
231 231 > ui.write('42\n')
@@ -51,9 +51,9 b' Install an extension that can sleep and '
51 51
52 52 $ cat >> sleepext.py << EOF
53 53 > import time
54 > from mercurial import cmdutil, commands
54 > from mercurial import registrar, commands
55 55 > cmdtable = {}
56 > command = cmdutil.command(cmdtable)
56 > command = registrar.command(cmdtable)
57 57 > @command('sleep', [], 'hg sleep')
58 58 > def sleep(ui, *args, **kwargs):
59 59 > time.sleep(0.1)
@@ -1,10 +1,10 b''
1 1
2 2 $ cat > loop.py <<EOF
3 > from mercurial import cmdutil, commands
3 > from mercurial import commands, registrar
4 4 > import time
5 5 >
6 6 > cmdtable = {}
7 > command = cmdutil.command(cmdtable)
7 > command = registrar.command(cmdtable)
8 8 >
9 9 > class incrementingtime(object):
10 10 > def __init__(self):
@@ -1,8 +1,8 b''
1 1
2 2 $ cat > adddrop.py <<EOF
3 > from mercurial import cmdutil
3 > from mercurial import registrar
4 4 > cmdtable = {}
5 > command = cmdutil.command(cmdtable)
5 > command = registrar.command(cmdtable)
6 6 > @command('debugadddrop',
7 7 > [('', 'drop', False, 'drop file from dirstate', 'FILE'),
8 8 > ('', 'normal-lookup', False, 'add file to dirstate', 'FILE')],
@@ -85,9 +85,9 b" don't allow marking or unmarking driver-"
85 85
86 86 $ cat > $TESTTMP/markdriver.py << EOF
87 87 > '''mark and unmark files as driver-resolved'''
88 > from mercurial import cmdutil, merge, scmutil
88 > from mercurial import merge, registrar, scmutil
89 89 > cmdtable = {}
90 > command = cmdutil.command(cmdtable)
90 > command = registrar.command(cmdtable)
91 91 > @command('markdriver',
92 92 > [('u', 'unmark', None, '')],
93 93 > 'FILE...')
@@ -37,14 +37,14 b" these predicates use '\\0' as a separator"
37 37 $ cat <<EOF > debugrevlistspec.py
38 38 > from __future__ import absolute_import
39 39 > from mercurial import (
40 > cmdutil,
41 40 > node as nodemod,
41 > registrar,
42 42 > revset,
43 43 > revsetlang,
44 44 > smartset,
45 45 > )
46 46 > cmdtable = {}
47 > command = cmdutil.command(cmdtable)
47 > command = registrar.command(cmdtable)
48 48 > @command('debugrevlistspec',
49 49 > [('', 'optimize', None, 'print parsed tree after optimizing'),
50 50 > ('', 'bin', None, 'unhexlify arguments')])
@@ -4,8 +4,8 b' Test UI worker interaction'
4 4 > from __future__ import absolute_import, print_function
5 5 > import time
6 6 > from mercurial import (
7 > cmdutil,
8 7 > error,
8 > registrar,
9 9 > ui as uimod,
10 10 > worker,
11 11 > )
@@ -30,7 +30,7 b' Test UI worker interaction'
30 30 > 'runme': runme,
31 31 > }
32 32 > cmdtable = {}
33 > command = cmdutil.command(cmdtable)
33 > command = registrar.command(cmdtable)
34 34 > @command('test', [], 'hg test [COST] [FUNC]')
35 35 > def t(ui, repo, cost=1.0, func='runme'):
36 36 > cost = float(cost)
General Comments 0
You need to be logged in to leave comments. Login now