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

11,900

Solution 1

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).

Solution 2

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.

Solution 3

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.

Share:
11,900
les2
Author by

les2

Programmer who currently specializes in enterprise Java, that is, Java, Spring, Hibernate, Maven, ... I'd like to build some real apps with Grails or Scala/Lift, but no one seems to be paying for that around here. I also do some JavaScript hackery when forced. For example, I did the map on this site: https://givelocal.drivetoendhunger.org/stats (Google Maps, GeoXML3, Dojo).

Updated on June 04, 2022

Comments

  • les2
    les2 about 2 years

    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

  • les2
    les2 almost 14 years
    of course, i blocked out the real password! (it's the crazily cryptic password that google generates for you for the source code repository -- i'm not that dense :)
  • HighCommander4
    HighCommander4 almost 12 years
    lol @ "that's a terrible password. You should come up with something better than eight stars."
  • HighCommander4
    HighCommander4 almost 12 years
    I have the same problem, but I use MSYS, not Cygwin. Any suggestions for me?
  • Mr. L
    Mr. L over 9 years
    Can someone give this guy a medal!
  • D.Tate
    D.Tate about 8 years
    @HighCommander4 but guys, hey guys, it's actually NINE stars..! See? See?!? **gets promptly booed off stage**