jcd
jcd

Reputation: 300

Creating a branch in SVN with files from different folders

I'm trying to setup the SVN methodology within my company. The thing is, I'd like to create a simple way for our programmers to complete their tasks. We work in task assignments, and a task only modifies a subset of our code base, usually taking objects (files) from various parts of our repository.

What I would like to do is, find a way to create a branch in SVN (imagine its name as the task code from a bug tracker) and inside that branch there's only the files related to that task.

Like this: there's a huge folder structure to separate various modules and parts of the system, but we'll take a small example: folders 1, 2 and 3 with some files inside.
We want to take a file from each folder, and create a branch in /branches/task_1 that contains a file from each folder.

I want to be able to checkout only that branch, with the three files and still have a way to merge the changes back into trunk, without changing the rest of trunk. Is this possible without too much work from our developers?

EDIT: The code is mainly SQL and PL/SQL code, so there's no build to be broken. Please focus on what I'm asking and not in the traditional Software Development paradigm.

EDIT2: Convinced the client to use a traditional SVN strategy! Win!

Upvotes: 0

Views: 1652

Answers (1)

prodigitalson
prodigitalson

Reputation: 60413

No, it's not going to be easy, and rightly so: this is a horrible strategy.

SVN is meant to be used as a series of snapshots of a tree of files. So cherry-picking from the tree into a branch and then trying to merge them back in is going to be tedious, though I don't think it's impossible. Plus you have to look at testing what happens in each task... That's going to have to be tested against the entire application anyhow. So it's kind of pointless to do what you're asking.

Now, if your stuff is modular by design you could store each module in a separate tree or a separate repo and then maintain the full application as a series of svn:externals, but that's actually going to make it more complex. I think you're probably going to be better off just doing things the standard way.

And if you don't think it's impossible, you could at least try to send me in some direction.

Well you will have to create branches from the CLI tool, since I don't know of any client that supports only copying a set of specific files to create a branch (unless that set of files is the contents of a specific dir in the repository). So you or the developer would have to do something like:

svn cp --parents SVNURL/trunk/file1.sql SVNURL/trunk/file2.sql SVNURL/branches/taskname

The problem is this is only going to copy the file from trunk, not any intermediate directory structure. So if you have anything but a flat file layout on trunk then you're probably going to get confused when you merge everything back, because whoever is doing the merge will have to just know where to merge everything.

The only way around this I can think of would be to copy each file individually like:

svn cp --parents SVNURL/trunk/file1.sql SVNURL/branches/taskname
svn cp --parents SVNURL/trunk/file2.sql SVNURL/branches/taskname
svn cp --parents SVNURL/trunk/migrations/file3.sql SVNURL/branches/taskname/migrations

I'm guessing what it boils down to is that when you merge you're going to have to do a cherry-pick merge one file at a time. Which seems like a whole lot of overhead to me for not a lot of benefit.

After your explanation of what you're dealing with here and the workflow, I still think this is a bad idea. You're just going to have a much easier time if you copy TRUNK to BRANCH and then only work on the files necessary. It's pretty easy to see what those files are by just looking at the log.

And if you are worried about your developers accidentally modifying things outside the scope of the task, I'm pretty sure you could just set the permission to only give them commit access to the existing files affected by the task + write permission to add new files if necessary.

Upvotes: 2

Related Questions