How to automatically keep remote mercurial repository at tip after pushes

Viewed 215

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.

2 Answers

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.

Related