comparison mercurial/chgserver.py @ 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 e5fbdc3659fc
children c93d046d4300
comparison
equal deleted inserted replaced
40109:413b6b10fdd5 40110:d1338b4e39d0
423 except error.ParseError as inst: 423 except error.ParseError as inst:
424 dispatch._formatparse(self.ui.warn, inst) 424 dispatch._formatparse(self.ui.warn, inst)
425 self.ui.flush() 425 self.ui.flush()
426 self.cresult.write('exit 255') 426 self.cresult.write('exit 255')
427 return 427 return
428 except error.Abort as inst:
429 self.ui.error(_("abort: %s\n") % inst)
430 if inst.hint:
431 self.ui.error(_("(%s)\n") % inst.hint)
432 self.ui.flush()
433 self.cresult.write('exit 255')
434 return
428 newhash = hashstate.fromui(lui, self.hashstate.mtimepaths) 435 newhash = hashstate.fromui(lui, self.hashstate.mtimepaths)
429 insts = [] 436 insts = []
430 if newhash.mtimehash != self.hashstate.mtimehash: 437 if newhash.mtimehash != self.hashstate.mtimehash:
431 addr = _hashaddress(self.baseaddress, self.hashstate.confighash) 438 addr = _hashaddress(self.baseaddress, self.hashstate.confighash)
432 insts.append('unlink %s' % addr) 439 insts.append('unlink %s' % addr)