CVS handling shared files

Alan Dayley plug-devel@lists.PLUG.phoenix.az.us
Fri Jul 12 17:25:02 2002


Well, it is not friendly to the idea of libraries.  And it is an old build 
environment setup years ago without consideration to automated version 
control.  Very sketchily (is that a word?), it works like this:

1.c, 2.c and 3.c are source files.
ProjectA makefile says to compile and link 1.c, 2.c and 3.c with "-DSWITCH1"
ProjectB makefile says to compile and link 1.c and 3.c with "-DSWITCH1"
ProjectC makefile says to compile and link 1.c and 2.c with "-DSWITCH2"

The -D switches on the compile command line will cause different code to be 
included in the build or different constant values or whatever in each 
compiled code file, according to the needs of the target project.  Thus, 
code is "shared" but slightly different needs are defined at build time.

Enough about that, on to evaluate my stepwise understanding of the solution 
you report.  Please try to follow this:

1. I import ProjectA (it has all the files), for example, into the repository.
2. I create the needed sandbox directory and files for ProjectC (without 
3.c) and import it into the repository.
3. I replace the file /cvsroot/ProjectC/1.c,v in the repository with link 
to the ProjectA file by deleting the ProjectC/1.c,v file and using the 
command "ln -s /cvsroot/ProjectA/1.c,v /cvsroot/ProjectC/1.c,v
4. From now on when I checkout ProjectC, I will get a copy of 1.c to my 
sandbox that actually came from the real file in ProjectA.

Did I get it?

Alan

At 05:50 PM 7/12/02 -0500, you wrote:
>On Fri, 12 Jul 2002, Alan Dayley wrote:
>
>Honestly, the right answer is if more than one product uses something it
>really should be a library not the same code over and over.  (i.e. code
>reuse should be used not code cut and paste) ;)
>
>However, I have been there and realize you making things right, might not
>be an immediate option. The right answer is use symlinks of the file
>system on the CVS repository.  Luckily your organization isnt the only one
>that has done a no no and needed a solution to remedy it. :)
>
>Basically you would create the file in one of the projects.  Then create
>symlinks (instead of real files) for all the other projects that use it.
>Then you can check out/commit from any project and all other projects are
>immediately updated.
>
>Hopefully that answers the question.
>
>-Derek
>
>_______________________________________________
>PLUG-devel mailing list  -  PLUG-devel@lists.PLUG.phoenix.az.us
>http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel