two repositories sharing the same store?

John Mulligan phlogistonjohn at asynchrono.us
Mon Jul 28 17:10:16 CDT 2008


On Monday 28 July 2008 15:06:35 David Baum wrote:
> What's the best way to create a second work area for a project I'm working
> on?  I know I can clone the original repository, but the drawback to this
> is that I have to make sure I push/pull between my two repositories to keep
> them in sync.  It also takes up a lot more space since I'm keeping 2 copies
> around of essentially the same data.

You easily can automate the synchronization with hooks. For example:

% hg clone /tmp/repo1 /tmp/repo2

% $EDITOR /tmp/repo2/.hg/hgrc
 [paths]
 default = /tmp/repo1
 [hooks]
 commit.sync-default = hg push default

Every time you commit in repo2, mercurial will automatically push to repo1. 
You can even update repo1's working dir by changing the hook:
  commit.sync-default = hg push default && hg -R default up

This is probably most useful when you are the only person working with those 
repos. This trick will even work with remote repositories, but without any 
space savings, it can be handy when you are coding on one system but can only 
test the code on another.

>
> I tried replacing .hg/store in the second repo with a soft link to the
> .hg/store for the original, and it seems to work for the few tests I tried,
> but I'm concerned about the robustness of this.  I expect hg would get very
> confused if two repos were changing the same store at the same time.  But
> assuming that I only run hg commands in one repo at a time, is this a safe
> solution, or is there cached information in .hg outside of store that
> assumes store hasn't changed?
>
> Is there some other mechanism for doing this?
>

See the previous replies on how clones use hard links to save space. So unless 
your repo is enormous just cloning is probably good enough.

> Thanks,
> Dave




More information about the Mercurial mailing list