Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using version control with non-hierarchical code?

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.

like image 466
user151841 Avatar asked Jan 31 '11 14:01

user151841


2 Answers

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.

like image 134
Avi Avatar answered Sep 24 '22 15:09

Avi


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

like image 45
Bert F Avatar answered Sep 23 '22 15:09

Bert F