Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do clone a Mercurial repository into a directory that already exists?

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.

like image 576
littlejim84 Avatar asked Sep 01 '10 21:09

littlejim84


People also ask

How do I clone a Mercurial repository?

Clone a remote Mercurial repositoryFrom the main menu, select Hg | Get from Version Control. The Get from Version Control dialog opens. In the dialog that opens, select Mercurial from the Version control list and specify the URL of the remote repository you want to clone. Click Clone.

How do I delete a Mercurial repository?

Once you decide that a file no longer belongs in your repository, use the hg remove command.

What is HG repository?

Strictly speaking, the term repository refers to the directory named . hg (dot hg) in the repository root directory. The repository root directory is the parent directory of the . hg directory. Mercurial stores its internal data structures – the metadata – inside that .


2 Answers

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.

like image 86
Ry4an Brase Avatar answered Oct 20 '22 06:10

Ry4an Brase


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
like image 20
Matthew Flaschen Avatar answered Oct 20 '22 06:10

Matthew Flaschen