comparison tests/test-commandserver.py @ 14889:a59058fd074a stable

hooks: redirect stdout/err/in to the ui descriptors when calling python hooks We need to make sure that python hooks I/O goes through the ui descriptors so it doesn't mess the command server protocol.
author Idan Kamara <idankk86@gmail.com>
date Sat, 09 Jul 2011 19:06:59 +0300
parents bb2cffe81a94
children b4c06b97dfe0
comparison
equal deleted inserted replaced
14884:c0ccd70df52c 14889:a59058fd074a
142 # but not for this repo 142 # but not for this repo
143 runcommand(server, ['init', 'foo']) 143 runcommand(server, ['init', 'foo'])
144 runcommand(server, ['-R', 'foo', 'showconfig']) 144 runcommand(server, ['-R', 'foo', 'showconfig'])
145 shutil.rmtree('foo') 145 shutil.rmtree('foo')
146 146
147 def hook(**args):
148 print 'hook talking'
149 print 'now try to read something: %r' % sys.stdin.read()
150
151 def hookoutput(server):
152 readchannel(server)
153 runcommand(server, ['--config',
154 'hooks.pre-identify=python:test-commandserver.hook', 'id'],
155 input=cStringIO.StringIO('some input'))
156
147 if __name__ == '__main__': 157 if __name__ == '__main__':
148 os.system('hg init') 158 os.system('hg init')
149 159
150 check(hellomessage) 160 check(hellomessage)
151 check(unknowncommand) 161 check(unknowncommand)
156 166
157 hgrc = open('.hg/hgrc', 'a') 167 hgrc = open('.hg/hgrc', 'a')
158 hgrc.write('[ui]\nfoo=bar\n') 168 hgrc.write('[ui]\nfoo=bar\n')
159 hgrc.close() 169 hgrc.close()
160 check(localhgrc) 170 check(localhgrc)
171 check(hookoutput)