##// END OF EJS Templates
dispatch: unify handling of None returned by a command function...
Yuya Nishihara -
r38015:6f9ac3cb default
parent child Browse files
Show More
@@ -256,7 +256,7 b' class server(object):'
256 self.cout, self.cerr)
256 self.cout, self.cerr)
257
257
258 try:
258 try:
259 ret = (dispatch.dispatch(req) or 0) & 255 # might return None
259 ret = dispatch.dispatch(req) & 255
260 self.cresult.write(struct.pack('>i', int(ret)))
260 self.cresult.write(struct.pack('>i', int(ret)))
261 finally:
261 finally:
262 # restore old cwd
262 # restore old cwd
@@ -87,7 +87,7 b' def run():'
87 req = request(pycompat.sysargv[1:])
87 req = request(pycompat.sysargv[1:])
88 err = None
88 err = None
89 try:
89 try:
90 status = dispatch(req) or 0
90 status = dispatch(req)
91 except error.StdioError as e:
91 except error.StdioError as e:
92 err = e
92 err = e
93 status = -1
93 status = -1
@@ -175,7 +175,7 b' def _formatargs(args):'
175 return ' '.join(procutil.shellquote(a) for a in args)
175 return ' '.join(procutil.shellquote(a) for a in args)
176
176
177 def dispatch(req):
177 def dispatch(req):
178 "run the command specified in req.args"
178 """run the command specified in req.args; returns an integer status code"""
179 if req.ferr:
179 if req.ferr:
180 ferr = req.ferr
180 ferr = req.ferr
181 elif req.ui:
181 elif req.ui:
@@ -208,9 +208,9 b' def dispatch(req):'
208
208
209 msg = _formatargs(req.args)
209 msg = _formatargs(req.args)
210 starttime = util.timer()
210 starttime = util.timer()
211 ret = None
211 ret = -1
212 try:
212 try:
213 ret = _runcatch(req)
213 ret = _runcatch(req) or 0
214 except error.ProgrammingError as inst:
214 except error.ProgrammingError as inst:
215 req.ui.warn(_('** ProgrammingError: %s\n') % inst)
215 req.ui.warn(_('** ProgrammingError: %s\n') % inst)
216 if inst.hint:
216 if inst.hint:
@@ -206,7 +206,7 b' log rotation'
206 committing changelog
206 committing changelog
207 updating the branch cache
207 updating the branch cache
208 committed changeset 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
208 committed changeset 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
209 result: None
209 result: 0
210 running: --debug commit -m commit2 -d 2000-01-02 foo
210 running: --debug commit -m commit2 -d 2000-01-02 foo
211 committing files:
211 committing files:
212 foo
212 foo
@@ -214,7 +214,7 b' log rotation'
214 committing changelog
214 committing changelog
215 updating the branch cache
215 updating the branch cache
216 committed changeset 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
216 committed changeset 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
217 result: None
217 result: 0
218 running: --debug log -r 0
218 running: --debug log -r 0
219 changeset: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
219 changeset: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
220 phase: draft
220 phase: draft
@@ -229,7 +229,7 b' log rotation'
229 commit1
229 commit1
230
230
231
231
232 result: None
232 result: 0
233 running: --debug log -r tip
233 running: --debug log -r tip
234 changeset: 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
234 changeset: 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
235 tag: tip
235 tag: tip
@@ -245,7 +245,7 b' log rotation'
245 commit2
245 commit2
246
246
247
247
248 result: None
248 result: 0
249 $ hg blackbox
249 $ hg blackbox
250 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updating the branch cache
250 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updating the branch cache
251 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updated served branch cache in * seconds (glob)
251 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updated served branch cache in * seconds (glob)
@@ -1,18 +1,18 b''
1 running: init test1
1 running: init test1
2 result: None
2 result: 0
3 running: add foo
3 running: add foo
4 result: 0
4 result: 0
5 running: commit -m commit1 -d 2000-01-01 foo
5 running: commit -m commit1 -d 2000-01-01 foo
6 result: None
6 result: 0
7 running: commit -m commit2 -d 2000-01-02 foo
7 running: commit -m commit2 -d 2000-01-02 foo
8 result: None
8 result: 0
9 running: log -r 0
9 running: log -r 0
10 changeset: 0:0e4634943879
10 changeset: 0:0e4634943879
11 user: test
11 user: test
12 date: Sat Jan 01 00:00:00 2000 +0000
12 date: Sat Jan 01 00:00:00 2000 +0000
13 summary: commit1
13 summary: commit1
14
14
15 result: None
15 result: 0
16 running: log -r tip
16 running: log -r tip
17 changeset: 1:45589e459b2e
17 changeset: 1:45589e459b2e
18 tag: tip
18 tag: tip
@@ -20,4 +20,4 b' user: test'
20 date: Sun Jan 02 00:00:00 2000 +0000
20 date: Sun Jan 02 00:00:00 2000 +0000
21 summary: commit2
21 summary: commit2
22
22
23 result: None
23 result: 0
General Comments 0
You need to be logged in to leave comments. Login now