Shared Repository Extension

This extension is not distributed with Mercurial.

Author: Brendan Cully


Note: As of 1.3, this extension will be made obsolete by the ShareExtension bundled with Mercurial.


This extension adds a --shared option to the clone command. When used, the destination will simply use a pointer to the source's repository, instead of copying it. This can make clones faster and cheaper, especially if your filesystem doesn't support hardlinks.

What is a typical usage scenario?


Note that an operation performed in any shared repository will immediately affect all of its peers. In effect, it is as though commit instantly and atomically pushes to the repository's parent and all of its siblings (i.e. any other shared clones of the same parent). But, of course, there is no push: commit simply writes in the .hg/store directory shared by all peers.

In particular, operations that destroy or modify history -- strip, rebase, etc. -- will also destroy or modify history in all of the shared clone's peers. For example, if you accidentally strip too many revisions in a shared clone, poof! you've just stripped those revisions from all of its peers. If you are experimenting with destructive operations, you should make a full clone and play around in it first.

Also, think carefully about the interaction between Mercurial Queues (MqExtension). Because .hg/patches is not shared between repositories, it's possible for different shared repositories to have independent patch queues. But MQ commands like qpush and qpop create and destroy history, so pushing/popping patches will affect all of the shared clone's peers. It's probably not a good idea to mix MQ and shared clones; if you do so, you should definitely avoid pushing/popping patches in one clone while another clone has patches applied.

In short, this is a small modification that deeply affects Mercurial's usual "clones are independent" contract. Make sure you understand what it does before you shoot yourself in the foot!


Configure your .hgrc to enable the extension by adding following lines:

sharedrepo = /path/to/

See also


SharedRepoExtension (last edited 2012-02-15 22:40:55 by ks3095497)