comparison mercurial/commands.py @ 2945:731f6b3d27c2

merge with self.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Fri, 18 Aug 2006 14:13:44 -0700
parents f4fc0575e8fa 2efa9b8aed30
children 6dddcba7596a
comparison
equal deleted inserted replaced
2942:f4fc0575e8fa 2945:731f6b3d27c2
3240 for k, v in external.iteritems(): 3240 for k, v in external.iteritems():
3241 if k.endswith('.' + name) or k.endswith('/' + name) or v == name: 3241 if k.endswith('.' + name) or k.endswith('/' + name) or v == name:
3242 return sys.modules[v] 3242 return sys.modules[v]
3243 raise KeyError(name) 3243 raise KeyError(name)
3244 3244
3245 def dispatch(args): 3245 def load_extensions(ui):
3246 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': 3246 added = []
3247 num = getattr(signal, name, None) 3247 for ext_name, load_from_name in ui.extensions():
3248 if num: signal.signal(num, catchterm) 3248 if ext_name in external:
3249 3249 continue
3250 try:
3251 u = ui.ui(traceback='--traceback' in sys.argv[1:])
3252 except util.Abort, inst:
3253 sys.stderr.write(_("abort: %s\n") % inst)
3254 return -1
3255
3256 for ext_name, load_from_name in u.extensions():
3257 try: 3250 try:
3258 if load_from_name: 3251 if load_from_name:
3259 # the module will be loaded in sys.modules 3252 # the module will be loaded in sys.modules
3260 # choose an unique name so that it doesn't 3253 # choose an unique name so that it doesn't
3261 # conflicts with other modules 3254 # conflicts with other modules
3271 try: 3264 try:
3272 mod = importh("hgext.%s" % ext_name) 3265 mod = importh("hgext.%s" % ext_name)
3273 except ImportError: 3266 except ImportError:
3274 mod = importh(ext_name) 3267 mod = importh(ext_name)
3275 external[ext_name] = mod.__name__ 3268 external[ext_name] = mod.__name__
3269 added.append((mod, ext_name))
3276 except (util.SignalInterrupt, KeyboardInterrupt): 3270 except (util.SignalInterrupt, KeyboardInterrupt):
3277 raise 3271 raise
3278 except Exception, inst: 3272 except Exception, inst:
3279 u.warn(_("*** failed to import extension %s: %s\n") % (ext_name, inst)) 3273 ui.warn(_("*** failed to import extension %s: %s\n") %
3280 if u.print_exc(): 3274 (ext_name, inst))
3275 if ui.print_exc():
3281 return 1 3276 return 1
3282 3277
3283 for name in external.itervalues(): 3278 for mod, name in added:
3284 mod = sys.modules[name]
3285 uisetup = getattr(mod, 'uisetup', None) 3279 uisetup = getattr(mod, 'uisetup', None)
3286 if uisetup: 3280 if uisetup:
3287 uisetup(u) 3281 uisetup(ui)
3288 cmdtable = getattr(mod, 'cmdtable', {}) 3282 cmdtable = getattr(mod, 'cmdtable', {})
3289 for t in cmdtable: 3283 for t in cmdtable:
3290 if t in table: 3284 if t in table:
3291 u.warn(_("module %s overrides %s\n") % (name, t)) 3285 ui.warn(_("module %s overrides %s\n") % (name, t))
3292 table.update(cmdtable) 3286 table.update(cmdtable)
3287
3288 def dispatch(args):
3289 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
3290 num = getattr(signal, name, None)
3291 if num: signal.signal(num, catchterm)
3292
3293 try:
3294 u = ui.ui(traceback='--traceback' in sys.argv[1:],
3295 readhooks=[load_extensions])
3296 except util.Abort, inst:
3297 sys.stderr.write(_("abort: %s\n") % inst)
3298 return -1
3293 3299
3294 try: 3300 try:
3295 cmd, func, args, options, cmdoptions = parse(u, args) 3301 cmd, func, args, options, cmdoptions = parse(u, args)
3296 if options["time"]: 3302 if options["time"]:
3297 def get_times(): 3303 def get_times():