Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get hg to prompt for my HTTP auth username / password on cygwin / windows?

At home, this works perfectly. I'm on another computer now (using cygwin) and hg push will not prompt for a username / password:

user@localhost /cygdrive/d/repos/upthescala/viewprotect
$ hg push https://viewprotect.googlecode.com/hg/
pushing to https://viewprotect.googlecode.com/hg/
searching for changes
abort: http authorization required

Here are the contents of my ~/.hgrc:

[http_proxy]
host=someproxy:8080

[ui]
username = My Name <myemail>

Thanks in advance for any advice!

Note: this seems to be a cygwin problem. When I try from the Windows prompt (cmd.exe), it works as expected:

D:\repos\upthescala\viewprotect>hg push https://viewprotect.googlecode.com/hg/
pushing to https://viewprotect.googlecode.com/hg/
searching for changes
http authorization required
realm: Google Code Mercurial Repository
user: myemailaddress
password: *********

remote: Success.

-- LES

like image 694
les2 Avatar asked Jun 25 '10 15:06

les2


3 Answers

Since it's HTTP you can always put the username and password right in the URL. That works on any website using http auth and in any browser.

hg push https://myemailaddress:*********@viewprotect.googlecode.com/hg/

Alternately, newer Mercurial versions have an auth section you can use.

BTW, that's a terrible password. You should come up with something better than eight stars.

like image 73
Ry4an Brase Avatar answered Oct 31 '22 15:10

Ry4an Brase


This could be caused by using a version of Mercurial that's tied to the Windows console subsystem. The binary distributed with Tortoise falls into this category. If this is the case, mercurial is expecting to use the console subsystem to prompt for credentials, but it does not find it when run from the Cygwin shell. In my case, installing and using the Cygwin version of mercurial fixed the problem, in addition to fixing color output. To check which version you're using, run 'which hg' (but you probably already knew that).

like image 8
Andrew Pritchard Avatar answered Oct 31 '22 15:10

Andrew Pritchard


To add to Andrew's comment:

installing and using the Cygwin version of mercurial fixed the problem,

This also fixed the problem for me, but it caused another problem which took me some time to figure out. When using the Cygwin version of hg, all files that had been cloned under TortoiseHG showed up as modified when I ran hg status, but no differences were shown for any of them when I ran hg diff.

The problem was that the permissions didn't match. Running chmod 644 .* -R in each repo resolved this problem.

like image 8
Jerry Avatar answered Oct 31 '22 14:10

Jerry