Search code examples
mercurial

How to automatically keep remote mercurial repository at tip after pushes


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.


Solution

  • 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%