Mercurial changegroup hooks not triggered; Linux - mercurial

I have a server which serves a "central" Mercurial repository; the team clones it and pushes their changes up to it via ssh. Hudson is installed on the same server (RHEL 5.5). I wish to trigger a Hudson build whenever anyone pushes to the central Mercurial repository. I also wish to send a notification email upon a push.
In ProjectName/.hg/.hgrc there is the following:
[hooks]
changegroup.hudson = wget http://Server.Name:8080//job/Project_Name/builds?delay=0sec >&2
If I use putty to ssh to this server and then issue the wget command, a build is successfully triggered, so I don't think it's a permissions issue.
Another hook is:
changegroup.notify = /the/path/.hg/hooks/notify
where notify is:
dest='comma separated list of email addresses'
repo="path/to/repository/"
subject="New changesets in $repo"
hg glog -l 10 -r $HG_NODE: | mail -s "$subject" $dest
When I run ./notify directly from the shell, the mail is sent correctly when I am in the central repository's path; if I execute notify from my home directory, the repository is not found and I get an empty email, but at least I get an email. I assume these hooks are just not being run.
What could be getting in the way? What should I check?

Run cd ProjectName; hg showconfig|grep hooks.
I bet your don't see your hooks, if this is exactly what you have:
In ProjectName/.hg/.hgrc there is the following:
Repository-wide hgrc is .hg/hgrc without dot.

Related

Get logs for repo remotely

Is there a way to get logs for a mercurial repo like so:
hg log -v "http://some/remote/repository"
instead of
hg log -v "C:\Users\Repo"
Mercurial does not support that operation. You firstly have to clone the repository.
See more here
If you have an http-served mercurial repository (which you seem to) you can get the log by going to http://some/remote/repository in your web browser. You can also start a web server on any repo by issuing the hg serve command. By default, this will start a web server on port 8000 and you can view it by going to http://repothost:8000/ or, if local, http://localhost:8000/.

how to setup a local repo of mercurial

here is the complete scenario:
Main repository: http://10.0.1.8:8000/ptest
I clone it at host 10.1.0.115, in the folder /LOCAL-REPO
Then, publish it using the command hg serve -p 9900 -d --webdir-conf hgwebconfig with the hgwebconfig file having
[paths]
ptest = /LOCAL_REPO/ptest
[web]
style = gitweb
now, on the same host 10.0.1.115, i create a seperate folder /QA and do:
hg clone http://10.0.1.115:9900/ptest
and get all the files, now i want to make changes and push them to the repo on
http://10.0.1.115:9900/ptest using the command
hg push ssh://10.0.1.115//??/ptest
I don't know what the correct value would be for ??. So the questions are:
How do i setup a user/password to push changes to this repo on 10.0.1.115?
what is the corect syntax in this case?
When I try to push the changes I get error:
hg push ssh://user#10.0.1.115/ptest
user#10.0.1.115's password:
remote: abort: There is no Mercurial repository here (.hg not found)!
abort: no suitable response from remote hg!
Do you really need to push via ssh:// when you pulled via http:// ?
After hg clone http://10.0.1.115:9900/ptest clone you should be able to push it via http as well, like hg push http://10.0.1.115:9900/ptest
But if you really need to push via ssh here it is: you must have your repository accessible under local account, e.g. if user is hg and it's homedir is /home/hg and you will have your repo in /home/hg/repository directory then you will be able to access it via command:
hg push ssh://hg#10.0.1.115/repository/
User/password will be same as to ssh onto user hg.

Review Board extension for mercurial not working on a Windows machine

I have installed mercurial and review board extension for mercurial on my Windows XP machine. In review board, I have added a repository say "MyRepo" which is on a central server.
I cloned "MyRepo" to my local machine, modified a file for testing and committed to my local repo. I haven't yet pushed it to my central repo.
Now I run "hg postreview" on my cloned local repo. I select "MyRepo" when postreview asks me to choose a repo.
I get a "File not found (207)" error after the command completion. Howver, my review request is uploaded to Review Board server but the diff file is not. Can you tell me what am I doing wrong or is there a patch or command I am not aware of?
I am a novice in DVCS and mercurial, so any help on this matter is really appreciated.
It sounds like you already pushed changes or did more than one commit to the clone (that diffs now more than one commit). Try this and refer to the changeset you created the clone from:
hg postreview -l -o --parent={changeset}
If you wan’t to submit further editings refer to the rewiewid and changeset your first postreview command submitted:
hg postreview -e {reviewid} -o --parent={changeset}

How to clone repository to a remote server/repository with Mercurial

Found myself quite confused today about this.
I create a blank repository locally(hg init), cloned it to working copy, added some code, commited and pushed it(to local repo obviously).
Now I need to share that repository with others. There is a server that has mercurial on it, how do I clone my repository to a remote one such that other developers can access it and pull/push code from/to it?
You'll want to check out the publishing repositories wiki page to get into web interfaces and access controls, but at it's most basic you can do something like this:
hg clone yourlocalrepo ssh://you#server//home/you/repo
That clones your local repo to a remote location of your choosing. Note that there are two double slashes in that URL.
You can't create a remote repo like that using http://, only ssh://. If all you have is http to hgweb.cgi you can 'hg init' an empty repo on the server and then hg push to it.
If your "official" repositories are served up by an HTTP server, and you want to create a repo in the central location based on a local machine's repo, here's one way. You need admin rights on the central server to do this.
e.g. I'm developing on windows, and my central repository is running on linux and served by lighttpd per the official guide. The server's central repo directory is /var/hg/repos/, owned by the user/group www-data. My local machine's IP is 10.1.10.100, and the repository I want to clone is named foo.
On the local machine, open a command prompt into the repository directory and type hg serve. This runs the local hg web server, which will allow the server to pull from it.
ssh into the central repo server, logging in as a user with sudo rights to www-data.
cd /var/hg/repos
sudo -u www-data hg clone http://10.1.10.100 foo
For those that come later and don't want to bother about the hassles of ssh for pushing changes to a server built to host repos, you can just init on the server, and then push as you do every other repo.
# on server:
cd repos/
mkdir myrepo
cd myrepo
hg init
cd ..
chown -R apache:apache myrepo
cd ..
vim hgweb.config
# change [paths]
[paths]
myrepo = /path/to/myrepo
# on your machine
# make sure you've configured hgrc correctly
[paths]
default = http://server/hg/repos/myrepo
hg push
# ???
# profit

Can not clone mercurial (hg) repository via http

I can't clone my repository via http:
abort: 'http://MYREPO' does not appear to be an hg repository!
Firstly, I created a new repo by hg init MYREPO followed by adding some file and commit.
The dir with my repo is password protected but there is no sign of problem because of it, I tried both methods of cloning:
(on my local machine)
hg clone http://MYREPO my_repo
and
hg clone http://user:password#MYREPO my_repo
Permissions of repo dir are: drwxrwxr-x
I can clone this very repository on my remote machine (the same repo is on) without any problems.
What could be possibly wrong?
UPDATE:
Looks like you're getting confusing between repository and hostname
If running "hg serve", "hg clone http://USER#HOST:8000" where host can be you machine's IP or the hostname (type "hostname" on linux or try "ping localhost"). You can change the default port from 8000 by passing a --port #### to hg serve.
If you want to do it over ssh, "hg clone ssh://USER#HOST//PATH/TO/YOUR/REPOSITORY". Suppose you made an repository in your home directory called MYREPO then you would do this: "hg clone ssh://USER#HOST/~/MYREPO"
You can only clone your repo via http is something is serving that repo over http. Mercurial provides a built in http server for you. Run "hg serve" while inside of your repo then attempt to clone it from another location (or another command shell). If you just want a local clone, you don't need to use http ("hg clone ").
Also, try "hg help clone" and "hg help serve" for details.
weirdly, cloning with ssh requires a non-intuitive extra forward slash.
this works for me on a host with ssh running on port 43211
hg clone ssh://example.com:43211//repos/myRepo ./myRepo
the double slash after the port number works, but a single slash there results in the ".hg not found" error
besszero is right, but why don't you clone using SSH if you are gonna use username and password anyway?
hg clone ssh://machine_ip//your/repo/location your_repo
It's also safer if you don't want to open another port for mercurial's http server and you don't need the hgweb features, the traffic is also encrypted. The only con is that you have to log in to checkout, but HTTP doesn't work for pushing back the changes, at least not in my experience.
Argh... One need to be careful with .htaccess configuration. In my case I needed to add 'hgwebdir.cgi' to the path to clone... Thanks for the answers though!
SSH seems logical but somehow I couldn't use it with user other than my local:
hg clone ssh://MY_REMOTE_USER#MYREPO
remote: abort: There is no Mercurial repository here (.hg not found)!