Setting username in Mercurial .hgrc file - mercurial

I have been browsing SO and Google for a solution to my basic problem, and so far I have had no luck.
I am brand new to Mercurial and have just installed it on my Mac. I am using it for personal version control and will not be communicating with a central server (yet).
When I try to commit files, I get abort: no username supplied (see "hg help config"). The common solution to this problem is putting the following in ~/.hgrc
[ui]
username = Firstname Lastname <firstname.lastname#example.net>
which I have done, but the error remains. It just won't read the file. Any suggestions?

For future reference: use
$ hg showconfig ui --debug
to see the settings from the [ui] section and to see the files Mercural reads for configuration settings. That should help you along if you ever have to debug such a case again.

Related

Mercurial HG 'pretxncommit.whitespace hook exited with status 1' but no hook specified

the title of this request says it all pretty much. I have no hooks defined in my .hgrc file, but I am getting this rollback message on running hg commit:
transaction abort!
rollback completed
abort: pretxncommit.whitespace hook exited with status 1
my hgrc file looks like this:
[paths]
default = 'the_address'
[ui]
username = 'my name and email address'
verbose = True
[extensions]
mq =
[diff]
git = 1
unified = 8
Just in case it is important. I am using Mercurial on Ubuntu 12.04 and I am trying to combine it with using a XAMPP installation (Apache friends) in the /opt/ directory, so I always have to run sudo before doing a commit.
Looking through SO and searching on the web, I found that this error is due to a hook with regard to trailing whitespace in the code (Compare this part of Mercurial: The definitive guide and also this SO entry on hooks). Strangely enough, I haven't defined this hook anywhere, so I also don't know how to remove it.
Any help in sorting this out would be appreciated. Thanks guys.
============================================================================
EDIT: Incorporating what smooth reggae suggested, I put a hgrc file in the home folder and the root folder and I adjusted the hgrc file in etc/mercurial just to find out what the deal with this problem is.
I am not sure, how much more information debug = True should give, but I didn't get particularly much. At the beginning of the commit message, I see the following now:
could not import hgext.hgext.mq (No module named hgext.mq): trying hgext.mq
could not import hgext.hgext.transplant (No module named hgext.transplant): trying hgext.transplant
So, this means, it can't find these two files, but why?
Thanks again for all your help.
EDIT2: Please note that the first EDIT is an unrelated issue and can be ignored for this particular question.
can you add debug = True under [ui] in your .hgrc file? That will give you some more output, which might offer some insight into the location of this hook

Problem with loading hggit extension in TortoiseHG

I'm trying to get the hggit extension to work under Windows 7 (64bit) using TortoiseHG (2.1.2). I followed the official setup instructions, i.e. cloning the hg-git repository and adding the "hggit = ..." line to the extensions section in my mercurial.ini file.
However the extension doesn't seem to be loaded. When trying to clone a repository I get the following error :
abort: repository git://... not found!
running
hg help hggit
results in
hg: unknown command 'hggit'
I also don't get any errors at all, no matter what I put in the extensions section of the mercurial.ini file.
Any ideas on what the problem might be ? Are there any log files at all that show me whether there are problems loading the extensions ?
Had the same problem, and in my case I forgot to specify the [extensions] line in the INI file.
Not working:
[ui]
username = My name <my#emailaddress.com>
hgsubversion=D:\Repotools\hg-svn\hgsubversion
hggit=D:\Repotools\hg-git\hggit
Working:
[ui]
username = My name <my#emailaddress.com>
[extensions]
hgsubversion=D:\Repotools\hg-svn\hgsubversion
hggit=D:\Repotools\hg-git\hggit
When you run the command hg help hggit it will report if the directory path is incorrect.
You should include what you have after hggit =
It should be pointing to the hggit subdirectory in the directory you cloned the repository into.
e.g. hggit=C:\hg-extensions\hg-git\hggit

Authenticating across mercurial subrepositories

I've got a mercurial repository, which pulls in dependencies using the subrepository functionality (as defined in the .hgsub file), but I'm struggling to get this working in TeamCity.
I've enabled the mercurial_keyring extension in order to save credentials (so when TeamCity provides authentication details for the root repository, it remembers them for the subrepositories). I've added an [auth] section to mercurial.ini too:
[auth]
bitbucket.schemes = https
bitbucket.prefix = https://bitbucket.org/xyz
bitbucket.username = xyz
If I run hg clone from the command line, I get prompted for a password once, and all is good. But the initial checkout when run via TeamCity fails with
VCS root: mercurial: https://bitbucket.org/xyz/projectA {instance id=23, parent id=1}, due to error: 'cmd /c hg update -C -r 4a08f587bb1f' command failed. stderr: abort: http authorization required stdout: pulling subrepo src\Common.Library from https://bitbucket.org/xyz/common.library
What am I missing, or am I going about this in completely the wrong way? Many thanks!
It seems that passing in credentials directly from TeamCity doesn't work with mercurial_keyring, but if I specify both username and password in plaintext in the mercurial.ini file (making sure it's accessible under the account the TeamCity build agent is running under), then this works.
The mercurial.ini file can be placed under <mercurial install path>\mercurial.ini if it does not work under user path.
Not ideal, but a solution... if anyone else finds a better one, please let me know.
May be it got fixed in last versions of TeamCity, but the following works for me:
Configure build agent service to run under domain account with
access to HG repositories (both root and subrepos)
Enable mercurial_keyring on build agent and add [auth] section
to mercurial config
Try to clone repository manually, enter
password. No need to wait until the whole repo is cloned -- it could
be terminated when "requesting all changes" message is shown.
Have fun -- now service will use keyring.
Probably the [auth] section shouldn't be added at all to the mercurial.ini for the TC agent. Team City uses --config auth... options to hg. I would also recommend not to use the mercurial_keyring but to set the username and password in VCS root - this is both secure and shared between different TC agents.
Not sure about the bitbucket, but in other cases usage of https scheme can require certificates configuration. This can be configured in mercurial.ini:
[web]
cacerts =
[hostfingerprints]
# hides mercurial warnings
domain-name = ab:cd:...:01
And last part: depending on .hgsub it might be needed to use VCS checkout mode "Automatically on agent" in Team City Version Control Settings.

Mercurial status not showing modified files

I'm running Mercurial 1.6.4 on my Debian server. It is not showing modified files that I know have been modified.
I'll modify a file, and an hg status will show:
! filename.txt
Then I run an hg status again and nothing shows up. I've tried to check in a file I know was modified, and alas, Mercurial says nothing was changed.
I even ran a hg st --all | grep 'M ' and it shows the modified files! Yet I can't check them in.
You should double-check that the inotify extension has not been enabled without your knowledge. Some older Debian packaged enabled it by default in the system-wide config. Use
hg showconfig --debug extensions
to list the enabled extensions and to list where each setting is read from. If it is enabled, you can disable it by adding
[extensions]
inotify = !
to your ~/.hgrc file or by editing the global config file.
I've tried to check in a file I know
was modified, and alas, Mercurial says
nothing was changed.
If you 'check it in', ie: commit, then status will not show it as modified because it has not been modified since the last commit.

create hgrc file to work on all paths on a machine, and for several repos

I want to create a hgrc file to set the username and password for all paths on some machine, e.g no matter in which directory I am in, hg clone some_path will always work without prompting for a username and a password (this is for an auto-deploy script). Also, it should work for several repos, not just one.
I followed the instructions and created a file: /etc/mercurial/hgrc.d/deploy.rc
it's contents:
[auth]
default.prefix= http://myrepo
default.username = myuname
default.password = pwd
But when I do
hg clone some_path I get abort: error: Connection refused.
What Am i doing wrong?
It should work. You can use hg showconfig to verify that it really is reading the config and that you don't just have a connection problem or something.
What version of hg are you using?
Also, it could be that your .hg/hgrc file is taking precedence over your global config.
Could you get the log of the server you try to connecgt to?
It should be listed there if at least the server address is correct.
And perhaps a hg clone -v something