Mercurial > hg-stable
changeset 29512:538d0003c9e0
commandserver: promote .cleanup() hook from chgserver
This allows us to unify _requesthandler.handle().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 21 May 2016 15:18:23 +0900 |
parents | 540c01a18bb7 |
children | e5b4d79a9140 |
files | hgext/chgserver.py mercurial/commandserver.py |
diffstat | 2 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/chgserver.py Sat May 21 15:12:19 2016 +0900 +++ b/hgext/chgserver.py Sat May 21 15:18:23 2016 +0900 @@ -353,6 +353,7 @@ self.capabilities['validate'] = chgcmdserver.validate def cleanup(self): + super(chgcmdserver, self).cleanup() # dispatch._runcatch() does not flush outputs if exception is not # handled by dispatch._dispatch() self.ui.flush()
--- a/mercurial/commandserver.py Sat May 21 15:12:19 2016 +0900 +++ b/mercurial/commandserver.py Sat May 21 15:18:23 2016 +0900 @@ -179,6 +179,10 @@ self.client = fin + def cleanup(self): + """release and restore resources taken during server session""" + pass + def _read(self, size): if not size: return '' @@ -329,6 +333,7 @@ sv = server(ui, self.repo, fin, fout) return sv.serve() finally: + sv.cleanup() _restoreio(ui, fin, fout) class _requesthandler(socketserver.StreamRequestHandler): @@ -348,6 +353,8 @@ raise except KeyboardInterrupt: pass + finally: + sv.cleanup() except: # re-raises # also write traceback to error channel. otherwise client cannot # see it because it is written to server's stderr by default.