tags:

views:

63

answers:

1

Often I want to have a main repository of source, shared by several "similar" projects. Each sub-project contains most of the same files, but is a specific configurable instance. That means there are usually a bunch of files and directories that need to be different for each instance.

In CVS I used to create the main repository and the secondary ones, then use the modules file to bind the two together for a specific name. In SVN I used svn:externals to tie back the secondary directories into the main one.

What works in Mercurial?

+1  A: 

It depends on the nature of the specific files that need to be different.
If you can transform them as template files, then you can:

  • have a main repo shared as a SubRepo (as said in the documentation: SubRepos are the "closest to what you can achieve with Subversion directories marked with the svn:externals property")
  • have "similar" projects which will:
    • include that main repo as a subrepo (referencing a specific revision)
    • run a versioned script which will take those template files and build the actual files with the right values per environment.

That way you keep separate the templates (in the main repo) and the values (which each similar projects know about depending on their specific environment).
That being said, not every variation of files can be processed as "templates to be instantiated".

VonC
So if I had a directory of source code (just to make it simple), and a directory of config files, I could create a couple of repos where the source is a sub-repo, but the config files are different? Does that work?
Paul W Homer
For example ConfigInstanceA and ConfigInstanceB, both have a common src dir that is shared ...
Paul W Homer
@Paul: once you need to share something, you make it a full repo of its own (here 'src' and 'config files' would be their own repos). MainA would reference "src" and "config", but would also reference directly some scripts able to take the template files within "config" and generate the right "configA" files (with the value for the "A" environment). Same thing for "MainB".
VonC
That way, "MainA" and "MainB" can share the same "src" and "config" contents, but can each generate different config files, because their generation scripts will have different values in each "Main" repo.
VonC