Show More
@@ -3242,18 +3242,11 b' def findext(name):' | |||
|
3242 | 3242 | return sys.modules[v] |
|
3243 | 3243 | raise KeyError(name) |
|
3244 | 3244 | |
|
3245 | def dispatch(args): | |
|
3246 | for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': | |
|
3247 | num = getattr(signal, name, None) | |
|
3248 | if num: signal.signal(num, catchterm) | |
|
3249 | ||
|
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(): | |
|
3245 | def load_extensions(ui): | |
|
3246 | added = [] | |
|
3247 | for ext_name, load_from_name in ui.extensions(): | |
|
3248 | if ext_name in external: | |
|
3249 | continue | |
|
3257 | 3250 | try: |
|
3258 | 3251 | if load_from_name: |
|
3259 | 3252 | # the module will be loaded in sys.modules |
@@ -3273,23 +3266,36 b' def dispatch(args):' | |||
|
3273 | 3266 | except ImportError: |
|
3274 | 3267 | mod = importh(ext_name) |
|
3275 | 3268 | external[ext_name] = mod.__name__ |
|
3269 | added.append((mod, ext_name)) | |
|
3276 | 3270 | except (util.SignalInterrupt, KeyboardInterrupt): |
|
3277 | 3271 | raise |
|
3278 | 3272 | except Exception, inst: |
|
3279 |
u.warn(_("*** failed to import extension %s: %s\n") % |
|
|
3280 | if u.print_exc(): | |
|
3273 | ui.warn(_("*** failed to import extension %s: %s\n") % | |
|
3274 | (ext_name, inst)) | |
|
3275 | if ui.print_exc(): | |
|
3281 | 3276 | return 1 |
|
3282 | 3277 | |
|
3283 | for name in external.itervalues(): | |
|
3284 | mod = sys.modules[name] | |
|
3278 | for mod, name in added: | |
|
3285 | 3279 | uisetup = getattr(mod, 'uisetup', None) |
|
3286 | 3280 | if uisetup: |
|
3287 | uisetup(u) | |
|
3281 | uisetup(ui) | |
|
3288 | 3282 | cmdtable = getattr(mod, 'cmdtable', {}) |
|
3289 | 3283 | for t in cmdtable: |
|
3290 | 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 | 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 | 3300 | try: |
|
3295 | 3301 | cmd, func, args, options, cmdoptions = parse(u, args) |
@@ -12,11 +12,13 b' demandload(globals(), "ConfigParser mdif' | |||
|
12 | 12 | |
|
13 | 13 | class ui(object): |
|
14 | 14 | def __init__(self, verbose=False, debug=False, quiet=False, |
|
15 |
interactive=True, traceback=False, parentui=None |
|
|
15 | interactive=True, traceback=False, parentui=None, | |
|
16 | readhooks=[]): | |
|
16 | 17 | self.overlay = {} |
|
17 | 18 | if parentui is None: |
|
18 | 19 | # this is the parent of all ui children |
|
19 | 20 | self.parentui = None |
|
21 | self.readhooks = list(readhooks) | |
|
20 | 22 | self.cdata = ConfigParser.SafeConfigParser() |
|
21 | 23 | self.readconfig(util.rcpath()) |
|
22 | 24 | |
@@ -34,6 +36,7 b' class ui(object):' | |||
|
34 | 36 | else: |
|
35 | 37 | # parentui may point to an ui object which is already a child |
|
36 | 38 | self.parentui = parentui.parentui or parentui |
|
39 | self.readhooks = list(parentui.readhooks or readhooks) | |
|
37 | 40 | parent_cdata = self.parentui.cdata |
|
38 | 41 | self.cdata = ConfigParser.SafeConfigParser(parent_cdata.defaults()) |
|
39 | 42 | # make interpolation work |
@@ -78,6 +81,8 b' class ui(object):' | |||
|
78 | 81 | for name, path in self.configitems("paths"): |
|
79 | 82 | if path and "://" not in path and not os.path.isabs(path): |
|
80 | 83 | self.cdata.set("paths", name, os.path.join(root, path)) |
|
84 | for hook in self.readhooks: | |
|
85 | hook(self) | |
|
81 | 86 | |
|
82 | 87 | def setconfig(self, section, name, val): |
|
83 | 88 | self.overlay[(section, name)] = val |
General Comments 0
You need to be logged in to leave comments.
Login now