Reputation: 4775
I'm working on a corporate source code tree that contains 100s of Maven sub-projects. Since each sub-project has its own layout of branches/
and tags/
sub-folders, the entire tree is laid out something like this:
root/
some/intermediate/dirs/
project1/
branches/
...
tags/
...
trunk/
...
project2/
branches/
...
tags/
...
trunk/
...
...
projectN/
branches/
...
tags/
...
trunk/
...
other/intermediate/dirs/
projectN+1/
...
I need to check out the trunk/
versions of all the projects but unfortunately, the command $ svn co protocol://path/to/repo/root/
checks out complete versions of tags and branches leaving me with thousands of redundant source trees and taking forever.
Moreover, N
is a very large number and it is not practicable for me to go in and check out each project's trunk individually.
Is there an svn
command that will enable me to skip tags/
and branches/
trees?
I found a blog that explains how to write a Java program to accomplish this using the SVNKit but I was hoping I could get it done using a one-liner from the command line.
Update: A solution using only the svn
executables is preferred, but if some shell scripting is needed, I would prefer a Windows batch script or, failing that, any bash
or zsh
script would do...
Upvotes: 4
Views: 1576
Reputation: 5359
Instead of --set-depth empty
I found suggestion use --set-depth=exclude
. F.e.:
svn update --set-depth=exclude <foldername>
It much more convenient. If in your example you do in directory some/intermediate/dirs/project1/
:
svn up --set-depth empty tags
And then:
svn up
Directory tags
will be appeared again and all content will be downloaded. So you need made updates from descendant directories only.
But with:
svn update --set-depth=exclude tags
Directory will be deleted, and you may do svn up
even from root/
directory! Update will come only to leaved directories!
To restore initial state and return all deleted in that way directories you may do:
svn up --set-depth infinity .
Upvotes: 1
Reputation: 703
A colleague (Knut) came up with this simple bash script, which checkouts the whole tree but without tags and branches. You can easily and quickly search there in the local copy:
function checkout() {
local base=${1%%/}
echo "checkout($base)"
for x in $(svn list $base); do
#echo "base=$base x=$x"
if [ "$x" = "trunk/" ]; then
echo $base
svn co $base/trunk ${base##*/}
elif [[ $x =~ ^(branches|tags)/$ ]]; then
true
elif [[ $x =~ ^.*/$ ]]; then
#echo "calling checkout $base/$x"
checkout $base/$x
fi
done
}
Use as "checkout myurl"
Upvotes: -1
Reputation: 30968
What you need is SVN sparse directories.
You'll want a skeleton structure, and fill in only the trunk
s when you get to them. Something like (Bourne shell syntax):
svn co --depth empty protocol://path/to/repo/root/
for in in some intermediate dirs; do svn up --set-depth empty $i; cd $i; done
svn up --depth immediates .
for i in *; do svn up --depth infinity $i/trunk; done
I'm assuming none of the directories in question contain spaces or shell metacharacters - add appropriate quoting if necessary.
Beware when using sparse directories - it's easy to lose track of what's excluded and what doesn't actually exist...
Upvotes: 7
Reputation: 56228
I don't know, which output format you need, but this batch line may help:
dir /s /b /ad |findstr /v /R "\<tags\> \<branches\>"
findstr
can search for "words" with "\<word\>"
, so moretags
or tagsmore
will not be excluded. See findstr /?
or if you are only interested in *trunk" subdirectories:
dir /s /b /ad |findstr "\<trunc\>"
Upvotes: 0