Mercurial > hg
changeset 40110:d1338b4e39d0
chgserver: catch Abort while parsing early args to shut down cleanly
_loadnewui() calls dispatcher functions, which may raise Abort if unparsable
arguments are passed in. The server should catch such errors and translate
them to the "exit 255" instruction so the client can finish the IPC session
cleanly.
Spotted while porting the chg client to Rust.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 07 Oct 2018 17:35:25 +0900 |
parents | 413b6b10fdd5 |
children | 9967818a85fa |
files | mercurial/chgserver.py |
diffstat | 1 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/chgserver.py Fri Oct 05 22:08:37 2018 +0900 +++ b/mercurial/chgserver.py Sun Oct 07 17:35:25 2018 +0900 @@ -425,6 +425,13 @@ self.ui.flush() self.cresult.write('exit 255') return + except error.Abort as inst: + self.ui.error(_("abort: %s\n") % inst) + if inst.hint: + self.ui.error(_("(%s)\n") % inst.hint) + self.ui.flush() + self.cresult.write('exit 255') + return newhash = hashstate.fromui(lui, self.hashstate.mtimepaths) insts = [] if newhash.mtimehash != self.hashstate.mtimehash: