My problem is the next one:
I work with several remote repos with Mercurial.
Every time I want to pull and update from the remote repos I write
hg pull -u
Once I introduce this command, I am asked for the password for every repo.
Is there a way to automate this behaviour in order to enter the password only once?
You can use the Mercurial Keyring extension, which is distributed with TortoiseHg.
Related
I created a mercurial repository on some file servers net share.
Is it possible to automatically get the remote repository updated to tip if somebody pushes its changes?
Because some other people (purely users) may copy the repositories content (rather than cloning, because of lack of .hg) and i want them to get the newest version.
Since it is a share on a simple NAS it would be good if the pushing client could invoke this update.
It seems that a hook on the changegroup event can solve this.
Add the following lines to the repository's configuration file (repo/.hg/hgrc)
[hooks]
changegroup = hg update
This solution was suggested on a slightly different question:
Cloning mercurial repo to the remote host
At least under windows this seems only to work on local repositories. The reason for this is, that hg tries run a cmd on the remote path that fails, since it does not support UNC paths as current direcory.
Adding explicitly the repository url fixes this, but its not client independent anymore.
[hooks]
changegroup = hg update -R %HG_URL%
You could treat the server repository as your "local working directory" and then PULL from your own PC to that location. If you use hg pull --update then it will automatically update the working folder to the latest.
One way to do this is to login to your NAS and physically run the hg command line program there. If not, you could also mount the NAS folder on your local PC and then chdir to its mapped local folder and use your local hg client to do so.
This might seem like an odd thing to do but Mercurial doesn't care which is the "clone" and which is the "server", you can swap them interchangeably in your workflow.
I'm using hgweb to publish my local repositories.
/project_path/project_name/.hg/.hgrc have:
[hooks]
changegroup.bitbucket = hg push ssh://hg#bitbucket.org/user/repo
When i'm use hg serve, all changegroup hooks working fine, but when i'm using hgweb through nginx with fcgi it's not working at all. I need those functionality to have some kind of backups.
It's mostly like Trust.
Mercurial needs to trust a hgrc file before it will parse/run it. If your /project_path/project_name/.hg/.hgrc file is owned by you then when you run hg serve with Mercurial running as you it's parsed/used. However, nginx runs as its own user, probably nginx which doesn't trust files owned by you, so when it invokes Mercurial those files are ignored (see Note).
That Mercurial trust link gives a better explanation and talks about how to say "nginx trusts X", but if it's a single-user system or you want everyone to trust you you can just throw a trust block in the system-global /etc/mercurial/hgrc file saying everyone trusts X.
Note: It doesn't actually just ignore those files it puts a warning on STDERR which in apache-land you'd find in your error.log, but in nginx land no one ever seems to find those warnings so I've no idea where nginx puts them.
I assume you have some kind of authentication issue here. When running hg serve from the command line, your ssh credentials are provided by an ssh-agent running in the background.
However, this does not work when running hgweb as a service, because there is no ssh-agent running in the background. If you would start an ssh-agent, there would be no possibility to enter the password for your ssh key.
Bitbucket uses ssh keys to authenticate you, so you can't just add your password to the above hg push command.
One possible solution would be to not use bitbucket as your backup, but a different mercurial server that let's you provide a simple password on the command line.
I'm afraid I can't help you further with this.
In Git, there is the command
git remote show <remote>
When properly configured, this will show you the status of the remote compared to your local repository, including whether there are pending changes in either. I can't find a similar command in Mercurial. Am I missing something or does it just not exist?
Perhaps hg summary --remote?
To compare local and remote repositories follow these steps:
go to local repo folder (use cd path_to_local_repo)
run "hg outgoing -p path_to_remote_repo" (without quotes)
See GenerateDiffBetweenRepositories
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!
I have a centralized Mercurial repository which I want to provide access to via SSH.
I did a chown root:developers repository -R on the repository directory, so all users in group 'developers' should have access.
So, I clone, add my initial files to the repository as user A, commit, push, done. Now, I go as user B, clone, add a file, commit, and push. But then, when I do a pull, an update, and change that file as user A and then try to push, I get
pushing to /var/hg/repository
searching for changes
1 changesets found
adding changesets
adding manifests
adding file changes
transaction abort!
rollback completed
abort: Permission denied: /var/hg/repository/.hg/store/data/test.i
Am I missing a configuration step? Should I not be using SSH?
EDIT I found that using the sticky bit solves the problem: How to set permissions so two users can work on the same hg repository?. Is this a bad solution?
Sticky group bit is the right way to do this. Also, it used to be the case that user's umasks needed to be set such that group read/write would be on for new files they add, but for the last year or two mercurial copies the permissions (not ownership) of the .hg directory in the repo itself on to newly created files, so the umask isn't as important.
Maybe you could be interested by mercurial-server: http://www.lshift.net/mercurial-server.html
mercurial-server is useful if you don't want to provide a shell to developers on server hosting mercurial central repository.
The Mercurial documentation says using the setgid flag is okay.