tags:

views:

1046

answers:

4

Mercurial supports push-style cloning of repositories to remote hosts, however newly cloned repositories don't contain working copies. Is there any 'hidden' option to make mercurial call update upon these cloned repos?

Here is an example:

1) hg init hello

2) hg clone hello ssh://somehost/hello

ssh://somehost/hello only contains .hg directory and I have to execute the following command in the shell in order to fill the working copy:

3) ssh somehost 'cd hello && hg update'

Is there any way to avoid step 3) ?

+4  A: 

There is no hidden option to force an update of a remote repository. Only one condition determines whether the update is performed (e.g., line 239 of hg.py in the Mercurial 1.0.1 source):

if dest_repo.local():

If you're going to do some work in the working copy, you're going to log in anyway, at which point running "hg update" is pretty easy, so there's not much motivation to relax the current constraint on remote clones.

Nathan Kitchen
+7  A: 

You can create a hook on the receiving side. Add the following section to your repo/.hg/hgrc

[hook]
changegroup = hg update

That should do it. Note that hooks are not cloned.

Nick
But if the repo is getting cloned to the remote host how can it contain these settings on the remote side? ;)
pachanga
This helps when you later want to push to the receiver again, without having to ssh to call update, again. The procedure that you describe in the question you really have to do only once, then its push push push. Thats where what I am proposing would simplify things. Push-and-forget. =P
Nick
A: 

i have the same problem, and unfortunately there is no simple solution to avoid step 3. mercurial doesn't check out the working copy remotely as "git clone" does, so you will always have this extra step when deploying your html files for the first time, for example.

tehfink
Install a hook on the server (once): `changegroup = hg update` in a `[hooks]` setting. Just do this once after having made the initial clone. Your repository will then update itself when you push.
Martin Geisler
i don't know why i'm being downvoted: the preferred solution is merely a workaround, as you still have to perform step 3 (ssh into the server).
tehfink
who cares if you must ssh **once**, the point is not having to do it every time
Lo'oris
+1  A: 

Yes, it should be [hooks] instead of [hook] in the accepted solution.

Konstantin