Bug 4056 - Push no longer prompts for password when capturing stdout in PowerShell
Summary: Push no longer prompts for password when capturing stdout in PowerShell
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: 2.7.1
Hardware: PC Windows
: urgent bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-08 16:38 UTC by Aaron Jensen
Modified: 2013-11-07 17:49 UTC (History)
4 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Jensen 2013-10-08 16:38 UTC
We have a PowerShell 3 script that automates the push/pull/merge/commit cycle. It pipes the output of commands so it can inspect them and convert them to objects so we can do PowerShell-y things with them (e.g. improved error handling).

Mercurial 2.5.4 would show the password prompt despite piping the command output. In Mercurial 2.7.1+, the password prompt no longer appears, so to the user it looks like our sync script hangs, when in fact, its just waiting for the user's response. We can't put passwords in our personal hgrc files because it is against corporate security policy.

Steps to reproduce:

1. In a repository that requires authentication when pushing, make a change, and try to push (commands shown are PowerShell):

PS> '' | sc newfile 
PS> hg add newfile
PS> hg ci -m "Adding newfile."
PS> hg push | % { Write-Host $_ }

Note that under Mercurial 2.7.1/2.7.2, the password prompt never appears.  In version 2.5.4, it does.
Comment 1 Matt Mackall 2013-10-08 18:19 UTC
Probably caused by this in 2.6:

http://www.selenic.com/hg/rev/be207d9b7e4b

Looks like the prompt is going to stdout instead of stderr.

Regression -> urgent

Can you test the following patch with:

http://mercurial.selenic.com/wiki/HackableMercurial

--- a/mercurial/ui.py	Mon Oct 07 15:23:52 2013 -0700
+++ b/mercurial/ui.py	Tue Oct 08 15:17:37 2013 -0700
@@ -665,7 +665,7 @@
         if not self.interactive():
             return default
         try:
-            self.write(self.label(prompt or _('password: '), 'ui.prompt'))
+            self.write_err(self.label(prompt or _('password: '), 'ui.prompt'))
             return getpass.getpass('')
         except EOFError:
             raise util.Abort(_('response expected'))
Comment 2 Aaron Jensen 2013-10-08 18:55 UTC
I downloaded, unblocked, and unzipped the 2.6 hackable Mercurial.  When I try to run any Mercurial command, I get:

    > hg push
    abort: failed to load Python DLL

I have Python 2.7 installed, but it isn't in my path.
Comment 3 Matt Mackall 2013-10-08 19:00 UTC
Hackable comes with its own copy of Python. Make sure you are explicitly running the hg.exe in the hackable bundle.
Comment 4 Aaron Jensen 2013-10-08 19:15 UTC
I'm explicitly using the path.  I should have shown that in my original trace:

    > C:\hg-2.6\hg.exe push
    abort: failed to load Python DLL

Process Monitor is reportin that hg.exe is looking for python26.dll in its directory, instead of the hg-python26 sub-directory.  Is there some additional setup besides downloading and unzipping?
Comment 5 HG Bot 2013-10-09 17:30 UTC
Fixed by http://selenic.com/repo/hg/rev/ba2be32d14f2
Matt Mackall <mpm@selenic.com>
ui: send password prompts to stderr again (issue4056)

(please test the fix)