質問

I use Mercurial on desktops, and then push local repositories to a centralized server. I noticed that this remote server does not hold local copies of files in its repositories (the directory is empty, except obviously for the .hg one).

What is the preferred way to populate these directories with local copies? (which in turn are used by various unrelated services on that server).

What I came up so far is to use a hook and hg archive to create a local copy. This would be a satisfactory solution but I need to configure a per-repository hgrc file (which is tedious but I did not find a way to centralize this in /etc/mercurial/hgrc). Maybe a global script (in /etc/mercurial/hgrc, run for each changegroup event)? (in that case how can I get the repository name to use in a if...then scenario?)

役に立ちましたか?

解決

If you can get access to the remote repository, you could install a hook for when changegroups come in, and perform an hg update when that happens.

A quick check shows this in the FAQ (question 4.21), but to summarize/duplicate: edit the .hg/hgrc file on the remote repository, and add the following lines:

[hooks]
changegroup = hg update

Whenever the remote repository gets pushed to (or when it performs a pull), it will update to the latest changeset.

Some caveats - this may fail if any changes have been made to the files on the remote side (you could use hg update -C instead). Also, if you have pushed any anonymous branches (which you would have to consciously force), you may not update to what you want to update to.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top