Josh
Josh

Reputation: 1356

SVN checkout only trunk from multiple directories

My question is similar to this question, but I am not using git.

I too am working on a huge legacy project, and I need to check out several projects.

I want to do a checkout of the parent directory for all the projects. When I do though, it pulls the branches and tags as well as the trunk for each directory. I only want the trunk for each project.

How can I check out the single parent directory for multiple projects WITHOUT pulling the branches and tags?

Upvotes: 1

Views: 2344

Answers (2)

dscran
dscran

Reputation: 21

I wrote a bash script for a similar purpose. I needed to check out the trunks in a large project with uneven depth in the sub-projects. This script uses the sparse directories feature alroc mentioned, and recursively goes through the subprojects until it finds a trunk folder. The trunk is then checked out with depth infinity.

#!/bin/bash

function svn_trunk()
{
    SUBDIRS=$(find "$1" -not -path '*/\.*' -not -path "$1" -type d)
    if [[ $SUBDIRS =~ "trunk" ]]; then
    svn up --set-depth infinity "$1/trunk"
    else
    for DIR in $SUBDIRS; do
        svn up --set-depth immediates "$DIR"
        svn_trunk "$DIR"
    done
    fi
}

if [ -d "$1" ]; then
    svn_trunk $1
else
    svn co --depth immediates "$1"
    svn_trunk .
fi

You can use the script with a repository url, or on a local working copy folder. It doesn't handle a second argument to set the name of the local working copy folder, but that's easily added...

Upvotes: 2

alroc
alroc

Reputation: 28194

Use Subversion's Sparse Directories feature to get the basic directory structure, then update the depth of the trunk directories to flesh them out.

svn checkout --depth immediates URL_TO_COMMON_PARENT LOCAL_DIR
svn update --set-depth infinity project1/trunk
svn update --set-depth infinity project2/trunk

Lather, rinse, repeat for each project.

I'm away from an svn repository at the moment so I haven't verified that this is 100% right, but I think it is.

Upvotes: 2

Related Questions