comparison mercurial/chgserver.py @ 30727:18eb63ec8475

chgserver: check type passed to S channel It currently only supports the "system" type. Add an explicit check.
author Jun Wu <quark@fb.com>
date Fri, 06 Jan 2017 16:12:25 +0000
parents dd897eb1699e
children 2957409449ac
comparison
equal deleted inserted replaced
30726:dd897eb1699e 30727:18eb63ec8475
310 data = '\0'.join(args) 310 data = '\0'.join(args)
311 self.out.write(struct.pack('>cI', self.channel, len(data))) 311 self.out.write(struct.pack('>cI', self.channel, len(data)))
312 self.out.write(data) 312 self.out.write(data)
313 self.out.flush() 313 self.out.flush()
314 314
315 length = self.in_.read(4) 315 if type == 'system':
316 length, = struct.unpack('>I', length) 316 length = self.in_.read(4)
317 if length != 4: 317 length, = struct.unpack('>I', length)
318 raise error.Abort(_('invalid response')) 318 if length != 4:
319 rc, = struct.unpack('>i', self.in_.read(4)) 319 raise error.Abort(_('invalid response'))
320 return rc 320 rc, = struct.unpack('>i', self.in_.read(4))
321 return rc
322 else:
323 raise error.ProgrammingError('invalid S channel type: %s' % type)
321 324
322 _iochannels = [ 325 _iochannels = [
323 # server.ch, ui.fp, mode 326 # server.ch, ui.fp, mode
324 ('cin', 'fin', 'rb'), 327 ('cin', 'fin', 'rb'),
325 ('cout', 'fout', 'wb'), 328 ('cout', 'fout', 'wb'),