Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN and code shared between several projects

Tags:

branch

svn

I have multiple projects in SVN. Each of these project sits in it's own trunk and branched for releases.

And there is a shared code which is used in each project. The question is what is the best way to handle the code.

Let me give couple of scenarios and the issues related to them

a) Put the shared code in separate trunk (or repository) and use svn:external.

In the case if we branched some of projects, there will be two problems:

  • Any modification of shared code which are made in trunk will be propagated to branch, because svn:external will pick up the changes
  • In the case if we will need at some moment go back and build exactly the code which was build for release, it will be hard for us to get exact code, because snv:external will again pick up latest copy of shared code, instead of code at the moment when project was brached.

As I understand there is one work around. As soon as we branch, we can modify svn:external to pick up exact revision of shared code. However, there are again two pitfalls:

  • You need remember to do this each time when you branch. (I hate such things, which is easy to forget).
  • You can't modify shared code, if you need to do a hotfix for the branched/released project.

b) Another solution is to branch shared code when the project is branched and change external to point to bracnhed copy of shared code.

  • Again, one of the problem is manual step, which is easy to forget
  • Another problem is merge problems. SVN will skip externals when you will try to merge changes in the project to the trunk. So, again, developer needs to remember to merge shared code manually.

Am I missing anything? Is there any reasonable way to handle this?

like image 232
Victor Ronin Avatar asked Oct 28 '09 16:10

Victor Ronin


People also ask

Is SVN a project management tool?

It can manage several projects and track progress, bugs, Test cases, etc.. There are several packages as well. If you are not a opensource developer, take a look at this as well. Show activity on this post.


1 Answers

Personally i keep a separate repository then use the [http://svnbook.red-bean.com/en/1.0/ch07s03.html svn:externals] attribute.

SVN Externals allow for you to link to other repositories (even ones you dont run e.g. the smarty subversion repo) when you run an svn update both your project and the external repo will be updated.

with SVN externals you can also link to specific revisions using somethign like http://path-to-project.com/svn/thing -r1234 for releases and other things that you need to keep static

Best practice IMHO is to always specify a revision then update the revision number as you make changes to the shared library so that you can keep track of WHY you updated this data. also keeps everything sane when you tag or branch the main project.

like image 66
Mike Valstar Avatar answered Sep 23 '22 02:09

Mike Valstar