13

I have a client's Django project that I'm developing locally, using Mercurial for version control. I push my local repository to my personal remote server (where I keep all my projects) and then when I come to deploy it (on whichever web server) I clone that respository there from my personal server.

This works fine on most servers (where I have total control) but I have a few projects where I'm deploying on to WebFaction. WebFaction is great, but a little unusual with it's setup, as I need to first declare the Django project as an 'application' through their control panel. This creates a few things automatically, such as an 'apache2', 'myproject', etc folder. It's this same folder though where I want to clone the repository from my personal remote server. Doing the usual hg clone command just doesn't work though as it says the destination folder already exists. There isn't much I can do about the contents of this folder really, so I need to work around this.

I'm not an expert at Mercurial and the only way I could seem to work it out is clone it to another folder and then moving all the contents (including the .hg) into the actual folder I want. This seems silly though...

I'm using Mercurial v1.6.2 (installed through easy_install). Could anyone share some light on this?

Many thanks.

littlejim84
  • 9,071
  • 15
  • 54
  • 77
  • You aren't the only one to have bumped into this feature of mercurial: http://mercurial.selenic.com/bts/issue1462 – msw Sep 01 '10 at 21:53

4 Answers4

23

Copying just the .hg dir definitely works, but you could also do a hg init and then hg pull http://remote/repo. A repo that has just been initalized has only the 000000000000000 changeset, so you can pull from any repo without getting the "unrelated repos" warning. This is essentially the same as hg clone --pull with a manual init.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
11

You can copy just the .hg folder, then revert or update to tip. E.g.:

cp -a src/.hg dest/
cd dest
hg up -C
Matthew Flaschen
  • 278,309
  • 50
  • 514
  • 539
1

you can either move the folder after the fact, or you can just make a symlink to it. my webfaction directory is actually symlinked, so i know it works fine.

ben
  • 21
  • 3
0

In the main, it looks like you might be trying to use Mercurial as an installation manager which is certainly not its design goal.

If I am reading you correctly, part of your source repository should be something like make deploy which puts the files into their proper places. Put another way, having a repository clone (in .hg) in your deployment directory seems odd and trouble-prone.

msw
  • 42,753
  • 9
  • 87
  • 112
  • 1
    Actually, a lot of folks do this and it works pretty great. Usually, one does a `push` to a production server which has `changegroupq hook that does an automatic `update`. There are a lot of questions here in stack overflow where just such a setup is recommended. Using a 'production' tag or the like as a target for the auto-update works very slick. – Ry4an Brase Sep 02 '10 at 10:53
  • @Ry4an: Here is at least one counter argument which calls out the same issues that were of concern to me. It isn't "right" but it was the only relevant one that my search turned up and I'd love to see a representative from the other side. If you are using a commit hook, then it seems there must be an implicit "install" script which is just triggered from hg. I've never done a direct deploy, so I'd like to learn what "boat" I've missed. http://stackoverflow.com/questions/2361708/using-hg-repository-as-web-site – msw Sep 02 '10 at 11:35
  • After looking at my project again, I must agree with msw. I'm over complicating things here, it seems that I should be just version controlling my actual Django project folder and not stuff around it. In this situation, that makes sense. Thanks. – littlejim84 Sep 03 '10 at 22:11
  • I don't see how this answers the question. I'm having the same trouble trying to create an automated build for mercurial since my very simple single-file checkout build script would like to already exist in the clone target rather than having to create one folder for 1 script file with everything else in a sub-folder. – ebyrob Jul 03 '18 at 14:03