If I read your question correctly, this is a simple matter of using svn copy to copy only the desired directories into a branch -- basically, a combination of answers from Mike Kushner and Ivan Krechetov. I think, however, it might be easier to understand after running through the steps yourself, so the rest of this post will create a sample repository and show the copies and merges.
I'm going to assume that you're using the "standard" repository layout, which at the top level has three sub-directories, trunk, branches, and tags. And that your 10, 20, 30, and 40 directories are under trunk. In other words:
trunk
10
20
30
40
branches
tags
And, as Mike pointed out, your goal will be to have a structure that looks like this:
trunk
10
20
30
40
branches
sandbox
20
40
tags
It's unclear from your posting (at least as-of the current edit), but you may have a directory structure in which 10, 20, et al are at the top level. In this case, you'll need to create a new top-level directory, which I'll call dev, so that your overall repository looks like the following:
10
20
30
40
dev
20
40
Note that you cannot create dev under 20. Well, physically you can, but you're almost guaranteed to break your build when doing so.
OK, so let's walk through an example, in which we create a new repository and put some files in it. You have to be able to run the svnadmin command (which you should be able to do, unless you have a paranoid sysadmin). So pick a temporary directory, and execute the following commands (I'm running Linux; if you're running Windows the commands will be the same, but you'll need to put a Windows-specific path in the REPO variable):
svnadmin create temp.repo
REPO="file://`pwd`/temp.repo"
svn co $REPO temp
This creates a new (empty) repository, and checks out a working copy of it. The second line needs some explanation: it simply creates the repository URL from the current directory. In my workspace directory, the URL looks like this:
file:///home/kgregory/Workspace/temp.repo
OK, now that you've got a working copy, let's create the sample directory structure and some files:
cd temp
svn mkdir trunk
svn mkdir branches
svn mkdir tags
svn commit -m "standard repo structure"
pushd trunk
svn mkdir 10
svn mkdir 20
svn mkdir 30
svn mkdir 40
svn commit -m "example sub-project structure"
echo "this doesn't change" > 10/dontchange.txt
svn add 10/dontchange.txt
echo "this does change" > 20/change.txt
svn add 20/change.txt
svn status
svn commit -m "example files"
popd
At this point we have the sample directories and two files in them. Here's the output from find, excluding subversion's hidden directories:
temp, 531> find . | grep -v svn
.
./tags
./trunk
./trunk/10
./trunk/10/dontchange.txt
./trunk/30
./trunk/20
./trunk/20/change.txt
./trunk/40
./branches
Next step is to create the sandbox directory, and make copies of the two directories that are going to be in it:
svn mkdir branches/sandbox
pushd branches/sandbox
svn copy ${REPO}/trunk/20 .
svn copy ${REPO}/trunk/40 .
svn commit -m "make development branch"
popd
This is the important part: I creating the branch and copies in my working directory, as a copy from the repository. Normally, you just copy trunk
into a child of branches
, using svn copy with two repository arguments. That doesn't work here, because we want only two children of trunk
.
After doing this, my working copy looks like this:
temp, 539> find . | grep -v svn
.
./tags
./trunk
./trunk/10
./trunk/10/dontchange.txt
./trunk/30
./trunk/20
./trunk/20/change.txt
./trunk/40
./branches
./branches/sandbox
./branches/sandbox/20
./branches/sandbox/20/change.txt
./branches/sandbox/40
At this point, you'd normally check out the development branch into a new working directory and work there. So I'll do that (after a cd back to my Workspace directory):
svn co ${REPO}/branches/sandbox sandbox
cd sandbox
And now make some changes:
vi 20/change.txt
svn commit -m "changed on branch"
OK, now it's time to merge back to the trunk. So go back to the workspace, and check out just the trunk:
svn co ${REPO}/trunk trunk
cd trunk
And merge from the sandbox. The merge process is described in the Subversion docs:
svn merge -r 4:5 ${REPO}/branches/sandbox
svn status
That last command should show you that only the file 20/change.txt
was affected by the merge. Since you didn't copy the 10 or 30 directories into the branch, they won't be touched by the merge.