5

I am looking at putting a code base that runs several website into version control. There are several instance of this code base running websites on different virtual servers.

The problem I'm grappling with is that each of these separate instances of more or less the same code have sub-directories with site-specific functions. But it seems that version control systems want to control the entire directory hierarchy.

For instance, each instance has the directory

/www/smarty/libs/plugins/

Where you'll find site-specific functions for smarty. When we are ready to put it into version control, the folder /www would be the root.

So one option is to have all the site-specific functions going out to all sites. I don't see a problem in and of itself, but it seems somehow architecturally 'wrong'. There would be a bunch of files that only belong to one deployment.

Another option is to have a separate repository for each site's specific files within the code base. But that sounds like it could quickly become a nightmare when trying to get new sites deployed properly.

What's the best way to do this? The version control system we're looking at is subversion.

user151841
  • 17,377
  • 29
  • 109
  • 171

5 Answers5

2

Generally, source control systems should be used to control source. They are not at their best completely controlling file hierarchies, permissions, and other related things. These are best left to deployment configuration.

How about having each of the projects and directories you need represented once in the version control system. Then, in a separate directory (perhaps called /build/), have the various configuration layouts. You might have an ant file that builds each site, or maven. Or you can use tools like Capistrano or Fabric to have more control over each deployment.

Avi
  • 19,934
  • 4
  • 57
  • 70
  • The build could be as simple as a shell script for each application that does `cp -r common-files /www; cp -r app1-plugins /www/smarty/libs/plugins`. – Tom Anderson Jan 31 '11 at 15:14
1

The tools are made to be flexible (generally), so here are some suggestions:

  1. Most VCS' allow you to ignore files and directories through some mechanism (e.g. Mercurial .hg ignore file), so you should be able to target what you want/should control versus what shouldn't be.

  2. Separate the files/directories into common resource project and site-specific projects and then use a build system to integrate them to create a deployable package. The build system can be as simple as a shell script or a more sophisticated framework. If its a really simple integration, the VCS may have some basic features for merging bases (e.g. Mercurial subrespositories).

Bert F
  • 85,407
  • 12
  • 106
  • 123
1

With subversion, you could have a bunch of repositories:

  • www be in a general repository
  • plugins each be in a site-specific repository

Then have nested working copies:

svn co http://www_repo www
cd www/smarty/libs
svn co http://foo_plugins_repo plugins

Tip: add plugins to svn:ignore property of www/smarty/libs

svn propset svn:ignore "plugins" www/smarty/libs

You could certainly do that with git too (through .gitignore), and probably with other version control systems but I don't know them.

(Alternatively you could skip the nested working copy part (which can freak some people out) and check out stuff side by side, but use a symlink in lieu of smarty/libs/plugins, while ignore still pertains)

Lloeki
  • 6,573
  • 2
  • 33
  • 32
1

You're missing a "build" step, which whould take the source in source control and create the deployment bundles for the different sites. Only one source package is needed, different build configurations create the different deployment packages. Don't try to directly put the deplyoment set into source control, it is not the source!

Lucero
  • 59,176
  • 9
  • 122
  • 152
0

I believe the best thing to do would be to create a top level directory in your repository for each site (Site-01, Site-02, etc) and inside those directories put the source tree. Then you can checkout the projects separately. I think it's acceptable and somewhat standard to use the same repository for all the projects your company is involved with.

My terminology might be off kilter, but the fundamental idea is sound, I believe.

jaydel
  • 14,389
  • 14
  • 62
  • 98
  • Wouldn't that make each subdirectory a separate instance of the code base, duplicating it unnecessarily, and then having to migrate changes between those subdirectories? – user151841 Jan 31 '11 at 14:46