Skip to content
Snippets Groups Projects
Commit 9fba795d authored by Idan Kamara's avatar Idan Kamara
Browse files

dispatch: assign I/O descriptors from the request to the ui

parent afccc64e
No related branches found
No related tags found
No related merge requests found
......@@ -28,8 +28,15 @@
def dispatch(req):
"run the command specified in req.args"
if req.ferr:
ferr = req.ferr
elif req.ui:
ferr = req.ui.ferr
else:
ferr = sys.stderr
try:
if not req.ui:
req.ui = uimod.ui()
if '--traceback' in req.args:
req.ui.setconfig('ui', 'traceback', 'on')
......@@ -31,6 +38,14 @@
try:
if not req.ui:
req.ui = uimod.ui()
if '--traceback' in req.args:
req.ui.setconfig('ui', 'traceback', 'on')
# set ui streams from the request
if req.fin:
req.ui.fin = req.fin
if req.fout:
req.ui.fout = req.fout
if req.ferr:
req.ui.ferr = req.ferr
except util.Abort, inst:
......@@ -36,3 +51,3 @@
except util.Abort, inst:
sys.stderr.write(_("abort: %s\n") % inst)
ferr.write(_("abort: %s\n") % inst)
if inst.hint:
......@@ -38,5 +53,5 @@
if inst.hint:
sys.stderr.write(_("(%s)\n") % inst.hint)
ferr.write(_("(%s)\n") % inst.hint)
return -1
except error.ParseError, inst:
if len(inst.args) > 1:
......@@ -40,6 +55,6 @@
return -1
except error.ParseError, inst:
if len(inst.args) > 1:
sys.stderr.write(_("hg: parse error at %s: %s\n") %
ferr.write(_("hg: parse error at %s: %s\n") %
(inst.args[1], inst.args[0]))
else:
......@@ -44,4 +59,4 @@
(inst.args[1], inst.args[0]))
else:
sys.stderr.write(_("hg: parse error: %s\n") % inst.args[0])
ferr.write(_("hg: parse error: %s\n") % inst.args[0])
return -1
......@@ -47,4 +62,5 @@
return -1
return _runcatch(req)
def _runcatch(req):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment