Mercurial > hg
comparison mercurial/commandserver.py @ 37995: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 | 6715e8035b4f |
children | c07424ec633c |
comparison
equal
deleted
inserted
replaced
37994:e9c588802529 | 37995:6f9ac3cb0987 |
---|---|
254 | 254 |
255 req = dispatch.request(args[:], copiedui, self.repo, self.cin, | 255 req = dispatch.request(args[:], copiedui, self.repo, self.cin, |
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 |
263 if '--cwd' in args: | 263 if '--cwd' in args: |
264 os.chdir(self.cwd) | 264 os.chdir(self.cwd) |