Pushing with mercurial: abort: no username supplied (see "hg help config") - mercurial

I'm not sure why but since today I have the problem with pushing my source to repo.
I got abort: no username supplied (see "hg help config")
The thing is that I have [ui] section in hgrc:
[ui]
username = My username
verbose = true
Where's the problem then?

Try doing:
hg --debug showconfig
that shows you all the configuration settings Mercurial is finding and where it's finding them. Since it looks like you're on windows one possibility is BOMs (byte order markers) at the front of your hgrc file. Nodepad likes to incorrectly put them in there.
In a pinch you can always do hg --config ui.username=Whatever_you_want commit, but that's a terrible long term solutions.
Lastly, one expects that error on commit, but you said you're getting it on push. I can't imagine how that could happen.

Either put a hgrc in the .hg directory in your repo or put a hgrc file in your home dir (then it covers all your projects) In the file you should write..
[ui]
username = Your Name <your#mail>

Related

Is there a Mercurial (hg) equivalent of `git remote -v`?

That is, does Mercurial have a command to tell where it was originally cloned from?
The following question seems to not serve that purpose: Mercurial repository identification
I can't recall special command for it, just because I always read repo's hgrc [paths] section by eye due to fact (hg help config)
The following special named paths exist:
"default"
The URL or directory to use when no source or remote is specified.
'hg clone' will automatically define this path to the location the
repository was cloned from.
but if you want hg command and trust hgrc's content (which can be edited at any time), you can use hg config paths.default which output key from repo-config, without warranties of using this URL for the whole lifetime of repo

Why doesn't my name and email appear in patches?

I have a remote repo cloned in my local computer.
After I make changes to a file, I commit, and then I do this to create a patch:
hg diff -U 8 -p -r PREVIOUS_REVISION_NUMBER file_name > patch_file
I send that patch_file for review.
But I don't see my name or email appearing anywhere in the patch.
My hgrc looks like this :
[ui]
username = My Name <myemail#domain.com>
[extensions]
mq =
[diff]
git = 1
unified = 8
Shouldn't I be seeing my name and email appearing in the patch?
I want further changesets of the remote repo to have my name for this commit, if it does get pushed.
Is there a better way of creating a patch, given my workflow?
(make changes, commit, create patch)
EDIT : I asked because I saw in other people's patches :
# HG changeset patch
# Parent some_long_code
# User name <email>
# Date ....
Don't use hg diff to generate the patch. Use hg export which will add the information that you are expecting as a header at the top of the file including the user and commit message.
Use hg help export for more information.
Shouldn't I be seeing my name and email appearing in the patch?
I don't see why. The patch is a document describing the difference between two files. Your personal identity is not relevant to that difference.

Mercurial: remote: abort: There is no Mercurial repository here (.hg not found)!

all,
I have searched for this problem for long time and tried different methods.
I want to maintain my code on the server through only SSH. But when I run this:
sudo hg clone -v ssh://carl#hostname//home/carl/Java/Projects/peta/
Mercurial keeps telling me remote: abort: There is no Mercurial repository here (.hg not found)!. Some articles said that the path should be correct and there should be a .hg directory there. But I have checked it for several times and I am sure there is a .hg folder at the right place.
I also tried
hg --config ui.remotecmd=/usr/bin/hg clone ssh://carl#hostname//home/carl/Java/Projects/peta/
But it failed as well. What other problem it could be? Thanks.
Solved
I finally fix the problem. Previously, I create a repository on my local machine, and scp all files (including .hg) on to the server. I try to remove .hg directory first, and create a repo on the server through ssh (hg init). Then hg clone works!
Extraction from hg help urls
Some notes about using SSH with Mercurial:
SSH requires an accessible shell account on the destination machine and
a copy of hg in the remote path or specified with as remotecmd.
path is relative to the remote user's home directory by default. Use an
extra slash at the start of a path to specify an absolute path:
ssh://example.com//tmp/repository
this means, at least, that you can't use the same URI and change only one/two slash it it: at least one path will be non-existent.
Consequence of the quote and error message: you must to debug (with any ssh-tool) and find correct path to needed directory. you can:
use scp (f.e) and copy known file from known location
SSH into remote host in interactive session and verify path (both?) by hand, i.e: ssh ..., cd ..., pwd, verify output of pwd
... any other debugger
When you'll get good path after login, you have to check next point of failure - .hg dir permissions
After verification of these checkpoints you'll get clone and some bonus in the form of understanding "What happened before"
HTH
I don't know if this really helps but, according to the FAQ:
hg clone ssh://USER#REMOTE/path/to/repo
They are using only one / after the USER#HOST. Maybe you can try that way.
César Bustíos's answer is almost correct, but that tries to clone from remote to local. To opposite way, we have to add the local path. In the case it is the current directory, it will be a dot.
hg clone . ssh://USER#REMOTE/path/to/repo
Hope it helps. :)
Running on Debian, to solve my problem, I have added the following line to my /var/lib/mercurial-server/.mercurial-server configuration file after the [paths]
[paths]
/ = ~/repos
...
And don't forget to issue this command afterwards: sudo -u hg /usr/share/mercurial-server/refresh-auth

How to commit to Sourceforge using Mercurial

I have directory named "Proyectos" with Django code inside.
I need to commit the project to Source Forge so my teacher can "download" all the code to his computer.
I think I should use some of these address:
http://phone-apps-djan.hg.sourceforge.net:8000/hgroot/phone-apps-djan/phone-apps-djan (read-only)
ssh://lucasab#phone-apps-djan.hg.sourceforge.net/hgroot/phone-apps-djan/phone-apps-djan (read/write)
I did this on Kubuntu:
lucas#lucas-Satellite-L305:~/Desarrollo/Python/Django/Proyectos$ hg clone http://phone-apps-djan.hg.sourceforge.net:8000/hgroot/phone-apps-djan/django-mercurial
but only the folder is created.
I'm a novice and didn't find how to do this. I followed some tutorials but I can't understand a lot of concepts.
I would appreciate some assistance with this, please.
Thanks in advance.
You have two different address to access your Mercurial repository on sourceforge :
http://phone-apps-djan.hg.sourceforge.net:8000/hgroot/phone-apps-djan/phone-apps-djan (read-only), like said after the address, this one is read-only, it is for everyone to clone your project, so they can see the sources and compile / use it. There's no authentication. When you use this address, Mercurial use the HTTP protocol to pull the changes.
ssh://lucasab#phone-apps-djan.hg.sourceforge.net/hgroot/phone-apps-djan/phone-apps-djan (read/write), you can write to your repository through this address, but you have to authenticate yourself (you'll have to enter your password) and Mercurial use the SSH protocol to do that. You can also see your sourceforge username in the address.
First of all, you must do another clone of your project with the second address, otherwise you won't be able to commit. Just cd in a new directory and do :
hg clone ssh://lucasab#phone-apps-djan.hg.sourceforge.net/hgroot/phone-apps-djan/phone-apps-djan
You should be prompted for your sourceforge account password.
Then, you can cd in the newly created directory, do all your changes, add files, etc. When you're done, you can do a hg commitand then a hg push to publish the modification to your repository. If you add new file to the directory don't forget to do a hg add or hg addremove.
You can find a really good and simple tutorial about mercurial on Hg Init, you should read it and try to understand the workflow before doing anything on sourceforge.
Good luck with your project :)
Many thanks to Rob Sobers and Krtek for their answers. I finally could add all my files to SourceForge. I followed their instructions and everything went fine, although I had some minor complications.
This is the answer to my questions step by step:
Over the folder "Proyectos" I did:
hg clone ssh://lucasab#phone-apps-djan.hg.sourceforge.net/hgroot/phone-apps-djan/phone-apps-djan and entered the password for my SourceForge account. A folder "phone-apps-djan" was created.
hg add after I cd into phone-apps-djan and copied all the files of my project into that folder.
hg commit. There was an error at this point: abort: no username supplied (see "hg help config"). So I created a file named .hgrc in my home dir and added these lines:
[ui]
username = my username at sourceforce <the mail address I supplied when registering>
verbose = True
Then I re-entered hg commit.
hg push. The follow error message was displayed: abort: repository default-push not found!. Then I just re-edited the .hgrc file created on the last step and added:
[paths]
default = ssh://lucasab#phone-apps-djan.hg.sourceforge.net/hgroot/phone-apps-djan/phone-apps-dja
I really don't understand what happened here because the .hg directory in my repo already contains a hgrc file with that path :(. Anyway, I did hg push again.
And that was all.
Doing hg clone downloaded the repository to your computer. Now, to update your working directory (so you can work with the files), type hg update.
When you're done making changes, type hg commit to record them. When you're ready upload your changes to SourceForge, type hg push http://path/to/repo. Make sure you push up to the correct repository!

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