##// END OF EJS Templates
dispatch: use the request to store the ui object...
Idan Kamara -
r14439:80c599ee default
parent child Browse files
Show More
@@ -12,8 +12,9 b' import cmdutil, encoding'
12 import ui as uimod
12 import ui as uimod
13
13
14 class request(object):
14 class request(object):
15 def __init__(self, args):
15 def __init__(self, args, ui=None):
16 self.args = args
16 self.args = args
17 self.ui = ui
17
18
18 def run():
19 def run():
19 "run the command in sys.argv"
20 "run the command in sys.argv"
@@ -22,9 +23,10 b' def run():'
22 def dispatch(req):
23 def dispatch(req):
23 "run the command specified in req.args"
24 "run the command specified in req.args"
24 try:
25 try:
25 u = uimod.ui()
26 if not req.ui:
27 req.ui = uimod.ui()
26 if '--traceback' in req.args:
28 if '--traceback' in req.args:
27 u.setconfig('ui', 'traceback', 'on')
29 req.ui.setconfig('ui', 'traceback', 'on')
28 except util.Abort, inst:
30 except util.Abort, inst:
29 sys.stderr.write(_("abort: %s\n") % inst)
31 sys.stderr.write(_("abort: %s\n") % inst)
30 if inst.hint:
32 if inst.hint:
@@ -37,12 +39,13 b' def dispatch(req):'
37 else:
39 else:
38 sys.stderr.write(_("hg: parse error: %s\n") % inst.args[0])
40 sys.stderr.write(_("hg: parse error: %s\n") % inst.args[0])
39 return -1
41 return -1
40 return _runcatch(u, req)
42 return _runcatch(req)
41
43
42 def _runcatch(ui, req):
44 def _runcatch(req):
43 def catchterm(*args):
45 def catchterm(*args):
44 raise error.SignalInterrupt
46 raise error.SignalInterrupt
45
47
48 ui = req.ui
46 try:
49 try:
47 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
50 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
48 num = getattr(signal, name, None)
51 num = getattr(signal, name, None)
@@ -59,7 +62,7 b' def _runcatch(ui, req):'
59 "type c to continue starting hg or h for help\n"))
62 "type c to continue starting hg or h for help\n"))
60 pdb.set_trace()
63 pdb.set_trace()
61 try:
64 try:
62 return _dispatch(ui, req)
65 return _dispatch(req)
63 finally:
66 finally:
64 ui.flush()
67 ui.flush()
65 except:
68 except:
@@ -490,8 +493,10 b' def _checkshellalias(ui, args):'
490 os.chdir(cwd)
493 os.chdir(cwd)
491
494
492 _loaded = set()
495 _loaded = set()
493 def _dispatch(ui, req):
496 def _dispatch(req):
494 args = req.args
497 args = req.args
498 ui = req.ui
499
495 shellaliasfn = _checkshellalias(ui, args)
500 shellaliasfn = _checkshellalias(ui, args)
496 if shellaliasfn:
501 if shellaliasfn:
497 return shellaliasfn()
502 return shellaliasfn()
@@ -602,7 +607,7 b' def _dispatch(ui, req):'
602 guess = repos[0]
607 guess = repos[0]
603 if guess and repos.count(guess) == len(repos):
608 if guess and repos.count(guess) == len(repos):
604 req.args = ['--repository', guess] + fullargs
609 req.args = ['--repository', guess] + fullargs
605 return _dispatch(ui, req)
610 return _dispatch(req)
606 if not path:
611 if not path:
607 raise error.RepoError(_("no repository found in %r"
612 raise error.RepoError(_("no repository found in %r"
608 " (.hg not found)") % os.getcwd())
613 " (.hg not found)") % os.getcwd())
General Comments 0
You need to be logged in to leave comments. Login now