Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/dispatch.py @ 5189:60acf1432ee0
Move cmdtable and reposetup handling out of extensions.py
A new function (extensions.extensions) allows the code that is
interested in those attributes to handle them directly.
This allows some cleanups of extensions.py. Notably, we can
remove the extensions.commandtable hack.
It also makes it easier to add standard extension attributes,
like a "hgwebsetup" function or a "helptable" dict that augments
the data in help.py, etc.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Fri, 17 Aug 2007 17:33:27 -0300 |
parents | 18a9fbb5cd78 |
children | da1658d63647 |
comparison
equal
deleted
inserted
replaced
5188:831ebc408ffb | 5189:60acf1432ee0 |
---|---|
236 argcount -= 1 | 236 argcount -= 1 |
237 else: | 237 else: |
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) |
244 config = _earlygetopt(['--config'], args) | 245 config = _earlygetopt(['--config'], args) |
245 if config: | 246 if config: |
267 path = lui.expandpath(rpath[-1]) | 268 path = lui.expandpath(rpath[-1]) |
268 lui = _ui.ui(parentui=ui) | 269 lui = _ui.ui(parentui=ui) |
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: |
275 util._fallbackencoding = fallback | 286 util._fallbackencoding = fallback |
276 | 287 |