comparison mercurial/commandserver.py @ 35652:40da2d7b4871

commandserver: restore cwd in case of exception The order of the statements was also changed a bit. But it shouldn't matter. Differential Revision: https://phab.mercurial-scm.org/D1859
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 14 Jan 2018 19:30:48 -0800
parents 3a119a423953
children 5bc7ff103081
comparison
equal deleted inserted replaced
35651:15cfd343d3a9 35652:40da2d7b4871
245 ui.setconfig('ui', 'nontty', 'true', 'commandserver') 245 ui.setconfig('ui', 'nontty', 'true', 'commandserver')
246 246
247 req = dispatch.request(args[:], copiedui, self.repo, self.cin, 247 req = dispatch.request(args[:], copiedui, self.repo, self.cin,
248 self.cout, self.cerr) 248 self.cout, self.cerr)
249 249
250 ret = (dispatch.dispatch(req) or 0) & 255 # might return None 250 try:
251 251 ret = (dispatch.dispatch(req) or 0) & 255 # might return None
252 # restore old cwd 252 self.cresult.write(struct.pack('>i', int(ret)))
253 if '--cwd' in args: 253 finally:
254 os.chdir(self.cwd) 254 # restore old cwd
255 255 if '--cwd' in args:
256 self.cresult.write(struct.pack('>i', int(ret))) 256 os.chdir(self.cwd)
257 257
258 def getencoding(self): 258 def getencoding(self):
259 """ writes the current encoding to the result channel """ 259 """ writes the current encoding to the result channel """
260 self.cresult.write(encoding.encoding) 260 self.cresult.write(encoding.encoding)
261 261