[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sharing files across directories - Redux

From: Jeff Pitman
Subject: Sharing files across directories - Redux
Date: Fri, 4 Jul 2003 11:00:56 +0800
User-agent: KMail/1.5.2

A bit of a delayed response, I know...

At 02:33 PM 9/25/2002, Matt Lyon wrote:

> Is there a way to share a single source file across multiple 
> directories in CVS, so that if it gets committed/merged in one 
> directory the update registers in both locations? I know that VSS has 
> this concept, and was wondering if CVS offers any sort of similar 
> functionality. I was thinking that perhaps this could be achieved with 
> some symlink trickery on the server-side?
On Wed, 25 Sep 2002 17:26:09 -0400, Frederic Brehm wrote:
> Actually, Ampersand modules share whole directories, not single files.
> CVS has no built-in way to share a single file across multiple 
> directories.

I was able to successfully share a single file by using some hackery in 
the CVSROOT/modules and Ampersand modules.  But, it doesn't scale very 
well, so I recommend it only if you need to share a couple of files.  
The scaling problem comes when you have to begin using a complex 
mneumonic/keyword system to cross-merge similar files across different 
directories from different projects.  

Some more disadvantages:

        * You cannot use branching to coax a different set of files to come out
        * You cannot re-check out the repository into your working copy and 
have clean output.  You will always get conflicts (even though it isn't 

Use this only when absolutely necessary.  Otherwise, follow Frederic's 
recommendation about changing the build system to accomodate your 
needs. (Eg. KDE does a symlink in the Working copies of their many 
projects to the admin/ directory to share the autoconf stuff around.)

Steps to share one file (all by editing CVSROOT/modules):

1. Add your project module and point to an Ampersand module:

# '-d' added for completeness, although optional
# Alias Working dir.    Repos. Module           Files or & Modules
foobar  -d foobar               foobar                  &shared-admin 

2. Select the files and location where you want to put this.  It will 
have to be a sub-directory off of the Working copy's root. 

shared-admin -d admin   baseline/admin missing
shared-init    -d src           baseline/src            main.c init.c   

Note: CVS admin directories for autoconf probably could just as well be 
shared as a whole, instead of individual files.  Therefore, the second 
"shared-init" provides a more interesting example where it can 
cross-mix different files between a set of baseline files and a set of 
project specific files.  Of course, branching and merging is left as an 
exercise for the reader!!


Alias   - Used to link modules together, used only under the scope of 
Working dir. - The name of the directory that is output starting at the 
base of your checkout.
Repos. Module - The repository module or its subdirectory
Ampersand (&) Modules - a link to another Alias found in CVSROOT/modules
Files - files that are found under the listed Repos. Module

I hope this has been an informative piece. Let the debate begin!

take care,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]