3

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?

Paul W Homer
  • 2,728
  • 1
  • 19
  • 25
  • Do you need some precisions about this answer? (since you just cancel the "tick" answer on it) – VonC May 20 '10 at 20:19
  • Sort of, sub-repos are good, but I'm not sure how this works for a distributed repository? So I pulled the tick to see if there are other answers. – Paul W Homer May 20 '10 at 20:45
  • no problem. Incidentally, subrepos works well with distributed repos, since they are represented by a unique revision key which can be shared amongst many other main repos needing to include that subrepo. – VonC May 20 '10 at 20:54
  • If I'm working on one parent with a subrepo, how do I get those changes distributed to the other subrepos? (I'm still in single repository mode :-) – Paul W Homer May 20 '10 at 21:20

1 Answers1

4

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".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 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 May 20 '10 at 20:48
  • For example ConfigInstanceA and ConfigInstanceB, both have a common src dir that is shared ... – Paul W Homer May 20 '10 at 20:50
  • @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 May 20 '10 at 20:57
  • 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 May 20 '10 at 20:58