Show More
@@ -3129,8 +3129,6 b' table = {' | |||||
3129 | "version": (version_, [], _('hg version')), |
|
3129 | "version": (version_, [], _('hg version')), | |
3130 | } |
|
3130 | } | |
3131 |
|
3131 | |||
3132 | extensions.commandtable = table |
|
|||
3133 |
|
||||
3134 | norepo = ("clone init version help debugancestor debugcomplete debugdata" |
|
3132 | norepo = ("clone init version help debugancestor debugcomplete debugdata" | |
3135 | " debugindex debugindexdot debugdate debuginstall") |
|
3133 | " debugindex debugindexdot debugdate debuginstall") | |
3136 | optionalrepo = ("paths serve showconfig") |
|
3134 | optionalrepo = ("paths serve showconfig") |
@@ -238,6 +238,7 b' def _earlygetopt(aliases, args):' | |||||
238 | pos += 1 |
|
238 | pos += 1 | |
239 | return values |
|
239 | return values | |
240 |
|
240 | |||
|
241 | _loaded = {} | |||
241 | def _dispatch(ui, args): |
|
242 | def _dispatch(ui, args): | |
242 | # read --config before doing anything else |
|
243 | # read --config before doing anything else | |
243 | # (e.g. to change trust settings for reading .hg/hgrc) |
|
244 | # (e.g. to change trust settings for reading .hg/hgrc) | |
@@ -269,6 +270,16 b' def _dispatch(ui, args):' | |||||
269 | lui.readconfig(os.path.join(path, ".hg", "hgrc")) |
|
270 | lui.readconfig(os.path.join(path, ".hg", "hgrc")) | |
270 |
|
271 | |||
271 | extensions.loadall(lui) |
|
272 | extensions.loadall(lui) | |
|
273 | for name, module in extensions.extensions(): | |||
|
274 | if name in _loaded: | |||
|
275 | continue | |||
|
276 | cmdtable = getattr(module, 'cmdtable', {}) | |||
|
277 | overrides = [cmd for cmd in cmdtable if cmd in commands.table] | |||
|
278 | if overrides: | |||
|
279 | ui.warn(_("extension '%s' overrides commands: %s\n") | |||
|
280 | % (name, " ".join(overrides))) | |||
|
281 | commands.table.update(cmdtable) | |||
|
282 | _loaded[name] = 1 | |||
272 | # check for fallback encoding |
|
283 | # check for fallback encoding | |
273 | fallback = lui.config('ui', 'fallbackencoding') |
|
284 | fallback = lui.config('ui', 'fallbackencoding') | |
274 | if fallback: |
|
285 | if fallback: |
@@ -10,8 +10,13 b' import util, sys' | |||||
10 | from i18n import _ |
|
10 | from i18n import _ | |
11 |
|
11 | |||
12 | _extensions = {} |
|
12 | _extensions = {} | |
13 | commandtable = {} |
|
13 | _order = [] | |
14 | setuphooks = [] |
|
14 | ||
|
15 | def extensions(): | |||
|
16 | for name in _order: | |||
|
17 | module = _extensions[name] | |||
|
18 | if module: | |||
|
19 | yield name, module | |||
15 |
|
20 | |||
16 | def find(name): |
|
21 | def find(name): | |
17 | '''return module with given extension name''' |
|
22 | '''return module with given extension name''' | |
@@ -55,19 +60,11 b' def load(ui, name, path):' | |||||
55 | except ImportError: |
|
60 | except ImportError: | |
56 | mod = importh(name) |
|
61 | mod = importh(name) | |
57 | _extensions[shortname] = mod |
|
62 | _extensions[shortname] = mod | |
|
63 | _order.append(shortname) | |||
58 |
|
64 | |||
59 | uisetup = getattr(mod, 'uisetup', None) |
|
65 | uisetup = getattr(mod, 'uisetup', None) | |
60 | if uisetup: |
|
66 | if uisetup: | |
61 | uisetup(ui) |
|
67 | uisetup(ui) | |
62 | reposetup = getattr(mod, 'reposetup', None) |
|
|||
63 | if reposetup: |
|
|||
64 | setuphooks.append(reposetup) |
|
|||
65 | cmdtable = getattr(mod, 'cmdtable', {}) |
|
|||
66 | overrides = [cmd for cmd in cmdtable if cmd in commandtable] |
|
|||
67 | if overrides: |
|
|||
68 | ui.warn(_("extension '%s' overrides commands: %s\n") |
|
|||
69 | % (name, " ".join(overrides))) |
|
|||
70 | commandtable.update(cmdtable) |
|
|||
71 |
|
68 | |||
72 | def loadall(ui): |
|
69 | def loadall(ui): | |
73 | result = ui.configitems("extensions") |
|
70 | result = ui.configitems("extensions") |
@@ -61,8 +61,10 b" def repository(ui, path='', create=False" | |||||
61 | """return a repository object for the specified path""" |
|
61 | """return a repository object for the specified path""" | |
62 | repo = _lookup(path).instance(ui, path, create) |
|
62 | repo = _lookup(path).instance(ui, path, create) | |
63 | ui = getattr(repo, "ui", ui) |
|
63 | ui = getattr(repo, "ui", ui) | |
64 |
for |
|
64 | for name, module in extensions.extensions(): | |
65 | hook(ui, repo) |
|
65 | hook = getattr(module, 'reposetup', None) | |
|
66 | if hook: | |||
|
67 | hook(ui, repo) | |||
66 | return repo |
|
68 | return repo | |
67 |
|
69 | |||
68 | def defaultdest(source): |
|
70 | def defaultdest(source): |
General Comments 0
You need to be logged in to leave comments.
Login now