6

I want to have a Mercurial repository set, but instead of having the .hg/ directory under the repository tree, I would love to move it somewhere away (like to other partition) from working copy.

Is it possible to do in such a way?

Martin Geisler
  • 1,271
  • 9
  • 23
kender
  • 287
  • 1
  • 5

2 Answers2

6

Since Mercurial 1.3, you can use the share extension to indirectly do what you want. Start by enabling the extension by adding the following to ~/.hgrc:

[extensions]
share =

Then create a normal repository on the partition where you want the .hg directory to be:

$ cd /mnt/bigdisk
$ hg init foo

Go to the place where you want the working copy to be and create a shared repository:

$ cd ~/src
$ hg share /mnt/bigdisk/foo

This creates a ~/src/foo repository for you. This repository will reference the /mnt/bigdisk/foo repository. There will still be a .hg folder in ~/src/foo, but it will be almost empty and thus very small. You operate on the shared repository like normal, but all commits go directly to the /mnt/bigdisk/foo repository.

The share extension works on all platforms where Mercurial runs (Windows, Mac OS X, Linux, ...) since the "symlink" is done internally by Mercurial, not via the filesystem.

Martin Geisler
  • 1,271
  • 9
  • 23
3

There's no way to do exactly what you want. The closest would be to have a symlink .hg pointing to the real one. Please see this thread.

Martin Geisler
  • 1,271
  • 9
  • 23
Matthew Flaschen
  • 868
  • 2
  • 7
  • 11