Show More
@@ -187,14 +187,20 b' class server(object):' | |||||
187 | # copy the uis so changes (e.g. --config or --verbose) don't |
|
187 | # copy the uis so changes (e.g. --config or --verbose) don't | |
188 | # persist between requests |
|
188 | # persist between requests | |
189 | copiedui = self.ui.copy() |
|
189 | copiedui = self.ui.copy() | |
|
190 | uis = [copiedui] | |||
190 | if self.repo: |
|
191 | if self.repo: | |
191 | self.repo.baseui = copiedui |
|
192 | self.repo.baseui = copiedui | |
192 | # clone ui without using ui.copy because this is protected |
|
193 | # clone ui without using ui.copy because this is protected | |
193 | repoui = self.repoui.__class__(self.repoui) |
|
194 | repoui = self.repoui.__class__(self.repoui) | |
194 | repoui.copy = copiedui.copy # redo copy protection |
|
195 | repoui.copy = copiedui.copy # redo copy protection | |
|
196 | uis.append(repoui) | |||
195 | self.repo.ui = self.repo.dirstate._ui = repoui |
|
197 | self.repo.ui = self.repo.dirstate._ui = repoui | |
196 | self.repo.invalidateall() |
|
198 | self.repo.invalidateall() | |
197 |
|
199 | |||
|
200 | for ui in uis: | |||
|
201 | # any kind of interaction must use server channels | |||
|
202 | ui.setconfig('ui', 'nontty', 'true', 'commandserver') | |||
|
203 | ||||
198 | req = dispatch.request(args[:], copiedui, self.repo, self.cin, |
|
204 | req = dispatch.request(args[:], copiedui, self.repo, self.cin, | |
199 | self.cout, self.cerr) |
|
205 | self.cout, self.cerr) | |
200 |
|
206 |
@@ -689,6 +689,11 b' class ui(object):' | |||||
689 | return default |
|
689 | return default | |
690 | try: |
|
690 | try: | |
691 | self.write_err(self.label(prompt or _('password: '), 'ui.prompt')) |
|
691 | self.write_err(self.label(prompt or _('password: '), 'ui.prompt')) | |
|
692 | # disable getpass() only if explicitly specified. it's still valid | |||
|
693 | # to interact with tty even if fin is not a tty. | |||
|
694 | if self.configbool('ui', 'nontty'): | |||
|
695 | return self.fin.readline().rstrip('\n') | |||
|
696 | else: | |||
692 | return getpass.getpass('') |
|
697 | return getpass.getpass('') | |
693 | except EOFError: |
|
698 | except EOFError: | |
694 | raise util.Abort(_('response expected')) |
|
699 | raise util.Abort(_('response expected')) |
@@ -294,6 +294,11 b' def mqoutsidechanges(server):' | |||||
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 |
|
296 | |||
|
297 | def getpass(server): | |||
|
298 | readchannel(server) | |||
|
299 | runcommand(server, ['debuggetpass', '--config', 'ui.interactive=True'], | |||
|
300 | input=cStringIO.StringIO('1234\n')) | |||
|
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']) | |
@@ -334,6 +339,19 b" if __name__ == '__main__':" | |||||
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) |
@@ -81,6 +81,7 b' defaults.tag=-d "0 0"' | |||||
81 | ui.slash=True |
|
81 | ui.slash=True | |
82 | ui.interactive=False |
|
82 | ui.interactive=False | |
83 | ui.foo=bar |
|
83 | ui.foo=bar | |
|
84 | ui.nontty=true | |||
84 | runcommand init foo |
|
85 | runcommand init foo | |
85 | runcommand -R foo showconfig ui defaults |
|
86 | runcommand -R foo showconfig ui defaults | |
86 | defaults.backout=-d "0 0" |
|
87 | defaults.backout=-d "0 0" | |
@@ -89,6 +90,7 b' defaults.shelve=--date "0 0"' | |||||
89 | defaults.tag=-d "0 0" |
|
90 | defaults.tag=-d "0 0" | |
90 | ui.slash=True |
|
91 | ui.slash=True | |
91 | ui.interactive=False |
|
92 | ui.interactive=False | |
|
93 | ui.nontty=true | |||
92 |
|
94 | |||
93 | testing hookoutput: |
|
95 | testing hookoutput: | |
94 |
|
96 | |||
@@ -238,6 +240,11 b' patch queue now empty' | |||||
238 | runcommand qqueue --active |
|
240 | runcommand qqueue --active | |
239 | foo |
|
241 | foo | |
240 |
|
242 | |||
|
243 | testing getpass: | |||
|
244 | ||||
|
245 | runcommand debuggetpass --config ui.interactive=True | |||
|
246 | password: 1234 | |||
|
247 | ||||
241 | testing hellomessage: |
|
248 | testing hellomessage: | |
242 |
|
249 | |||
243 | o, 'capabilities: getencoding runcommand\nencoding: ***' |
|
250 | o, 'capabilities: getencoding runcommand\nencoding: ***' |
General Comments 0
You need to be logged in to leave comments.
Login now