Mercurial > public > mercurial-scm > hg-stable
diff mercurial/dispatch.py @ 38038:6f9ac3cb0987
dispatch: unify handling of None returned by a command function
A command function may return None in place of 0 just for convenience, but
dispatch() doesn't need to inherit that property. This patch makes it be
friendly to callers.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 12 May 2018 15:33:09 +0900 |
parents | e9c588802529 |
children | 48853a927757 |
line wrap: on
line diff
--- a/mercurial/dispatch.py Fri May 11 21:23:48 2018 -0700 +++ b/mercurial/dispatch.py Sat May 12 15:33:09 2018 +0900 @@ -87,7 +87,7 @@ req = request(pycompat.sysargv[1:]) err = None try: - status = dispatch(req) or 0 + status = dispatch(req) except error.StdioError as e: err = e status = -1 @@ -175,7 +175,7 @@ return ' '.join(procutil.shellquote(a) for a in args) def dispatch(req): - "run the command specified in req.args" + """run the command specified in req.args; returns an integer status code""" if req.ferr: ferr = req.ferr elif req.ui: @@ -208,9 +208,9 @@ msg = _formatargs(req.args) starttime = util.timer() - ret = None + ret = -1 try: - ret = _runcatch(req) + ret = _runcatch(req) or 0 except error.ProgrammingError as inst: req.ui.warn(_('** ProgrammingError: %s\n') % inst) if inst.hint: