TortoiseHG stop credentials prompt - mercurial

I'm trying to stop tortoiseHG from prompting me for credentials every time i do something. I can't seem to find out how to fix this. From what I've read you need to specify username and enable mercurial_keyring?
My mercurial.ini file
[ui]
username=myFirstName myLastName myFirstName.myLastName#somecompany.com
[auth]
servername.prefix = servername
servername.username = myFirstName myLastName myFirstName.myLastName#somecompany.com
servername.schemes = https://servername.somecompany.com/fogbugz/kiln
[extensions]
mercurial_keyring=
I have updated global settings; surely I do not need to add settings for every repository that I add?

mercurial.ini:
[auth]
servername.prefix = servername
servername.username = login
You should specify your login as username, not your Mercurial's display name.
UPD: The display name (specified in [ui] section) is used when you commit changes. It's written into the changeset and becomes a part of history.
The name used for authentication (login) is specified in [auth] section. This is what you have to type in (along with password) every time when keyring doesn't work properly.

Related

LFTP: save username/password for specific server?

Can I save a username/password pair for an ftp server in some local configuration file, so that lftp will find them automatically when connecting to that server?
Background: I have script which will be used by multiple users, with different username/password pairs, to sync some generated content from a repository to an ftp server. It would be nice not to have to enter our usernames/passwords by hand each time. Since ftp passwords are sent in cleartext, we are all using low-value passwords for this, so storing the passwords in cleartext in a local config file is acceptable.
You can use ~/.netrc file or lftp bookmarks.
Add something like this to ~/.netrc:
machine your.server.example.com login your_login password your_password
Then lftp will pick the password when opening ftp://your_login#your.server.example.com, and it will use your_login automatically when opening "your.server.example.com" without the URL syntax.
When using bookmarks, do "set bmk:save-passwords true" (default is false), then save the current session to bookmarks under a name, then "open bookmark_name" will use the login/password pair. The bookmarks file is plain text, so you can even add the URL with login/password by any text editor. To use a common bookmarks for all users set LFTP_HOME environment variable to a common directory.
Just some more details about lftp bookmarks:
First add line set bmk:save-passwords yes to the main lftp config file /etc/lftp.conf.
Now every user can add his own bookmark:
lftp -c "bookmark add SiteName ftp://user:password#sitename.com/path"
When using lftp in a script just use: lftp -c "open SiteName && lcd MyLocalDir && mput ./"*

Mercurial subrepos and bitbucket accounts

I have a team set up on bitbucket with multiple users, and I'm using the keyring extension for mercurial. I need to set up a subrepo, and in the .hgsub file I need to provide the url for the subrepo.
If I use https://bitbucket.org/team/subrepo then the user needs to authenticate each time they try to pull.
If I use https://userX.bitbucket.org/team/subrepo then each user will need to authenticate with userX's password.
If I use https://team.bitbucket.org/team/subrepo then each user will need the team's password.
Is there a way I can set it up so that the authentication can be saved using the keyring extension, but still have separate credentials for each user, without using ssh?
Yes, you can enter your authentication information into your config file. The documentation for this is here.
In the auth section of each user's config file you can enter the following details:
[auth]
bb.schemes = http https
bb.prefix = bitbucket.org/team
bb.username = userX
The bb part is just a tag to group the settings together - you can use what you like and you can have more than one set if you have more than one Mercurial server that you use.
The example settings say that all repositories that start http://bitbucket.org/team or https://bitbucket.org/team should use the username of userX. The keyring extension will take care of the password after that.

HG4Idea hangs on windows

Has anybody else had an issue with the new Intellij HG4IDEA not working in Windows? Whenever I try to pull from a remote repository it just hangs, never asking for my ssh username/password.
My initial thought was that I should set my username/password in mercurial.ini somehow.
It just sits like this indefinably, if I try to cancel it it will not stop.
You need to configure it to work with your keys without password or
use ssh client that is able to ask password in a dialog window, like
TortoisePlink.exe.
When using console SSH client, there is no way for IDEA to see if it's
requesting passwords and provide them (it's just not supported, so ssh
client must either work without asking anything in the console or ask
a password via dialog).
See also
http://youtrack.jetbrains.net/issue/IDEA-62230 and http://youtrack.jetbrains.net/issue/IDEA-56004.
In order to get Intellij 10 to work with hg4idea I just changed my mercurial.ini file in my user directory of windows.
# Generated by TortoiseHg setting dialog
[extensions]
hgext.convert=
[ui]
username = myusername
[trusted]
users = *
groups = *
[ui]
ssh="C:\Program Files\TortoiseHg\bin\TortoisePlink.exe"
The key was to set ssh= to a client that supports prompting for passwords.

Mercurial error: abort no username supplied

Problem on WindowsXP (likely will happen on all Win installs), first time using Mercurial. I found the answer in an inobvious place so I'm asking/answering the question myself so others don't have to search like I did.
First time using Mercurial on machine.
Add new repoz:
c:\bla\>hg add
no problem.
Next, commit:
c:\bla\hg commit
error:
abort: no username supplied (see "hg help config")
Solution:
On my Windows install, the Mercurial.ini did not get propagated. It also needs a user email added to it.
Take the default Mercurial.ini file found at in the Mercurial executable install directory (C:\Program Files\Mercurial\Mercurial.ini on my machine)
and copy it to your user home dir (C:\Documents and Settings\myName on winXP).
On a Windows 7 install there is no default .ini, you will need to create a new one in C:\Users\myName.
Then edit that .ini file. Find this area. The username needs an email set. It will be blank--add your email name here.
[ui]
; editor used to enter commit logs, etc. Most text editors will work.
editor = notepad
username = userEmail#domain.example
This fixed the problem for me.
I'm sorry, but why do you call this a problem? Mercurial asks you to see hg help config, and this help text explicitly tells you how to add a username -- I know since I wrote that help text :-)
How should we improve the error message to make this more clear?
However, we've managed to screw this up by making hg help config include help for all config settings. So the nice little example of how to set the username:
[ui]
username = Your Name <your#email.example>
is now lost in the noise (add this to ~/.hgrc, creating the file if necessary). I've opened an issue for this.
On Windows XP I do not see an ini file.
After creating the repository using the command hg init,
I added a file with the name hgrc to the folder .hg
With the following content:
[ui]
editor = notepad
username = zamboni#icemachine.example
no matter Windows or Linux, hg looks the <repo>/.hg/hgrc file for valid configuration. As in "hg help config" says, you only have to add at the end of that file the following lines:
[ui]
username = YOUR NAME <EMAIL#HOST.EXAMPLE>
verbose = true
save and hg commit -m 'test'
If you are using TortoiseHg, you can add [UI] settings easily
Right clicking in any folder Explorer to access the TortoiseHg menu.
From the flyout TortoiseHg menu choose Global Settings
From the interface click the Edit File
Add the [UI] settings to the end
[ui]
username = YourName <YourEmail#SomeAddress.com>
verbose = true
Save and you are done
Here is what worked like a charm for me on Windows XP:
Go to the folder C:\Program Files\Mercurial\hgrc.d assuming you have installed Mercurial to C:\Program Files\Mercurial\.
You should see a Mercurial.RC file in there.
Copy the file to C:\Documents and Settings\ [USERNAME]\
Rename Mercurial.RC to Mercurial.ini.
Edit the [ui] section like so:
[ui]
; editor used to enter commit logs, etc. Most text editors will work.
editor = notepad
verbose = True
username = userEmail#domain.example
I had the same problem. What helped me was to put [ui] and username = firstname lastname on separate lines of the ~/.hgrc file. Putting these two things on one line did not work and led to the error.
This problem still exists. The mercurial.ini file is ignored no matter where you put it.
No mercurial.ini file is created during installation. I created one in the Mercurial install directory, but it had no effect. I copied it to %USERPROFILE% and then to %HOME%, but neither one works.
Putting .hgrc in the HOME directory works.
The documentation ("hg help config") needs to be fixed.
Configure you .hgrc like this:
[ui]
username = your name <youremail#host.example>
verbose = True
NOTE! Do not leave out the [ui] part
This is a problem because in the help file the path to the specified config file does not exist, we have to copy the Mercurial.ini from program files directory to USER directory, maybe this is a problem coming from the installer on windows.
#Kevin Won: you forgot to add the line:
verbose = True

Store password in TortoiseHg

Is there a way to configure TortoiseHg to store my password?
I have a project hosted on Google Code that I access using TortoiseHg. Whenever I want to push changes to Google Code TortoiseHg prompts me for a username and password. Google Code requires me to use an auto-generated password, and it gets quite repetitive to look it up every time.
Both existing answers suggest storing your username and password unencrypted in plain-text, which is a bit of a no-no.
You should use the Keyring extension instead, as it has been specifically designed for securely saving authentication passwords. It already comes bundled with TortoiseHg, so all you have to do is activate it by writing the following in your mercurial.ini file:
[extensions]
mercurial_keyring=
You will also have to associate your username with the push url by editing your repository-specific .hg\hgrc file like in the example below:
[paths]
default = https://<your_username>#bitbucket.org/tortoisehg/thg
For more details on associating your username with the url, see the Repository Configuration (SMTP) section of the Keyring extension page.
Three steps, watch screenshot.
Note: This stores your password in plaintext.
Security warning
Although this answer is accepted as of 2017-09-15, it is not a recommended solution. You should never store your passwords in plain text. Use the mercurial_keyring extension instead. See another answer here.
You can change your push URL to https://username:password#hostname.com/repo.
This is explained in Google Code's and Mercurial's FAQs.
EDIT: Mercurial FAQ explains another way to do it:
With Mercurial 1.3 you can also add an auth section to your hgrc file:
[auth]
example.prefix = https://hg.example.net/
example.username = foo
example.password = bar
If you want to configure it via TortoiseHg, Repository Setting dialog is available.
After opening the dialog, please switch to 'Sync' tab.
You can add a path with HTTPS auth information.
http://tortoisehg.bitbucket.io/manual/2.9/settings.html#module-web.settings
Simply modify the hgrc file in the .hg directory of your local repository so it looks like this:
[paths]
default = https://name:password#yourproj.googlecode.com/hg/
where name is your Google Code login without the gmail/googlemail bit e.g. 'fredb' (not fredb#gmail.com), password is the Google-generated password, and yourproj is the name of your GC project. So something like:
default = https://fred:xyz123#fredproj.googlecode.com/hg/
This works for me using SSH. I know the password it's in text plain, but this is not a problem in this project.
You have to change myUser and MyOPas for your credentials and the path to: TortoisePlink.exe.
Edit the mercurial.ini
[reviewboard]
password = myPass
[ui]
username = myUser
ssh = "C:\Program Files\TortoiseHg\lib\TortoisePlink.exe" -l myUser -pw myPass
If you want to store the password in mercurial.ini and it doesn't work anymore after you upgrade to TortoiseHg 4.9 or higher a possible solution is to add the port to the prefix:
[auth]
tax.prefix = http://server:8080
tax.username = cerveser
tax.password = mypassword