Show More
@@ -187,14 +187,20 b' class server(object):' | |||
|
187 | 187 | # copy the uis so changes (e.g. --config or --verbose) don't |
|
188 | 188 | # persist between requests |
|
189 | 189 | copiedui = self.ui.copy() |
|
190 | uis = [copiedui] | |
|
190 | 191 | if self.repo: |
|
191 | 192 | self.repo.baseui = copiedui |
|
192 | 193 | # clone ui without using ui.copy because this is protected |
|
193 | 194 | repoui = self.repoui.__class__(self.repoui) |
|
194 | 195 | repoui.copy = copiedui.copy # redo copy protection |
|
196 | uis.append(repoui) | |
|
195 | 197 | self.repo.ui = self.repo.dirstate._ui = repoui |
|
196 | 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 | 204 | req = dispatch.request(args[:], copiedui, self.repo, self.cin, |
|
199 | 205 | self.cout, self.cerr) |
|
200 | 206 |
@@ -689,7 +689,12 b' class ui(object):' | |||
|
689 | 689 | return default |
|
690 | 690 | try: |
|
691 | 691 | self.write_err(self.label(prompt or _('password: '), 'ui.prompt')) |
|
692 | return getpass.getpass('') | |
|
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: | |
|
697 | return getpass.getpass('') | |
|
693 | 698 | except EOFError: |
|
694 | 699 | raise util.Abort(_('response expected')) |
|
695 | 700 | def status(self, *msg, **opts): |
@@ -294,6 +294,11 b' def mqoutsidechanges(server):' | |||
|
294 | 294 | # repo.mq should be recreated to point to new queue |
|
295 | 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 | 302 | def startwithoutrepo(server): |
|
298 | 303 | readchannel(server) |
|
299 | 304 | runcommand(server, ['init', 'repo2']) |
@@ -334,6 +339,19 b" if __name__ == '__main__':" | |||
|
334 | 339 | hgrc.write('[extensions]\nmq=\n') |
|
335 | 340 | hgrc.close() |
|
336 | 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 | 356 | os.chdir('..') |
|
339 | 357 | check(hellomessage) |
@@ -81,6 +81,7 b' defaults.tag=-d "0 0"' | |||
|
81 | 81 | ui.slash=True |
|
82 | 82 | ui.interactive=False |
|
83 | 83 | ui.foo=bar |
|
84 | ui.nontty=true | |
|
84 | 85 | runcommand init foo |
|
85 | 86 | runcommand -R foo showconfig ui defaults |
|
86 | 87 | defaults.backout=-d "0 0" |
@@ -89,6 +90,7 b' defaults.shelve=--date "0 0"' | |||
|
89 | 90 | defaults.tag=-d "0 0" |
|
90 | 91 | ui.slash=True |
|
91 | 92 | ui.interactive=False |
|
93 | ui.nontty=true | |
|
92 | 94 | |
|
93 | 95 | testing hookoutput: |
|
94 | 96 | |
@@ -238,6 +240,11 b' patch queue now empty' | |||
|
238 | 240 | runcommand qqueue --active |
|
239 | 241 | foo |
|
240 | 242 | |
|
243 | testing getpass: | |
|
244 | ||
|
245 | runcommand debuggetpass --config ui.interactive=True | |
|
246 | password: 1234 | |
|
247 | ||
|
241 | 248 | testing hellomessage: |
|
242 | 249 | |
|
243 | 250 | o, 'capabilities: getencoding runcommand\nencoding: ***' |
General Comments 0
You need to be logged in to leave comments.
Login now