Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/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 | 1120b1e2f975 |
comparison
equal
deleted
inserted
replaced
21194:476069509e72 | 21195:9336bc7dca8e |
---|---|
185 args = self._read(length).split('\0') | 185 args = self._read(length).split('\0') |
186 | 186 |
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() |
199 | |
200 for ui in uis: | |
201 # any kind of interaction must use server channels | |
202 ui.setconfig('ui', 'nontty', 'true', 'commandserver') | |
197 | 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 |
201 ret = (dispatch.dispatch(req) or 0) & 255 # might return None | 207 ret = (dispatch.dispatch(req) or 0) & 255 # might return None |