Mercurial > public > mercurial-scm > hg
comparison tests/test-commandserver.py @ 21195:9336bc7dca8e stable
cmdserver: forcibly use L channel to read password input (issue3161)
Command server is designed to use the channel protocol even if the server
process is accessible to tty, whereas vanilla hg should be able to read
password from tty in that case. So it isn't enough to swap sys.stdin:
# works only if the server process is detached from the console
sys.stdin = self.fin
getpass.getpass('')
sys.stdin = oldin
or test isatty:
# vanilla hg can't talk to tty if stdin is redirected
if self._isatty(self.fin):
return getpass.getpass('')
else:
...
Since ui.nontty flag is undocumented and command-server channels don't provide
isatty(), this change won't affect the other uses of ui._isatty().
issue3161 also suggests to provide some context of messages. I think it can
be implemented by using the generic templating function.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 26 Apr 2014 18:13:06 +0900 |
parents | e811b93f2cb1 |
children | 26d2fb899637 |
comparison
equal
deleted
inserted
replaced
21194:476069509e72 | 21195:9336bc7dca8e |
---|---|
291 | 291 |
292 runcommand(server, ['qpop', '--all']) | 292 runcommand(server, ['qpop', '--all']) |
293 os.system('hg qqueue --create foo') | 293 os.system('hg qqueue --create foo') |
294 # repo.mq should be recreated to point to new queue | 294 # repo.mq should be recreated to point to new queue |
295 runcommand(server, ['qqueue', '--active']) | 295 runcommand(server, ['qqueue', '--active']) |
296 | |
297 def getpass(server): | |
298 readchannel(server) | |
299 runcommand(server, ['debuggetpass', '--config', 'ui.interactive=True'], | |
300 input=cStringIO.StringIO('1234\n')) | |
296 | 301 |
297 def startwithoutrepo(server): | 302 def startwithoutrepo(server): |
298 readchannel(server) | 303 readchannel(server) |
299 runcommand(server, ['init', 'repo2']) | 304 runcommand(server, ['init', 'repo2']) |
300 runcommand(server, ['id', '-R', 'repo2']) | 305 runcommand(server, ['id', '-R', 'repo2']) |
332 check(obsolete) | 337 check(obsolete) |
333 hgrc = open('.hg/hgrc', 'a') | 338 hgrc = open('.hg/hgrc', 'a') |
334 hgrc.write('[extensions]\nmq=\n') | 339 hgrc.write('[extensions]\nmq=\n') |
335 hgrc.close() | 340 hgrc.close() |
336 check(mqoutsidechanges) | 341 check(mqoutsidechanges) |
342 dbg = open('dbgui.py', 'w') | |
343 dbg.write('from mercurial import cmdutil, commands\n' | |
344 'commands.norepo += " debuggetpass"\n' | |
345 'cmdtable = {}\n' | |
346 'command = cmdutil.command(cmdtable)\n' | |
347 '@command("debuggetpass")\n' | |
348 'def debuggetpass(ui):\n' | |
349 ' ui.write("%s\\n" % ui.getpass())\n') | |
350 dbg.close() | |
351 hgrc = open('.hg/hgrc', 'a') | |
352 hgrc.write('[extensions]\ndbgui=dbgui.py\n') | |
353 hgrc.close() | |
354 check(getpass) | |
337 | 355 |
338 os.chdir('..') | 356 os.chdir('..') |
339 check(hellomessage) | 357 check(hellomessage) |
340 check(startwithoutrepo) | 358 check(startwithoutrepo) |