views:

251

answers:

2

Hi,

Does anyone know of an easy way to import a legacy project, whose "version control system" is a series of dated folders, into SVN, so that the history of the revisions is preserved?

The project I inherited was not under version control, and there are hundreds of folders, each dated like: 2006-11-26, 2006-11-27, etc... Thankfully it appears they did a pretty good job of diligently creating the folders, even when (for weeks) nothing changed.

What I'd love is a script/tool that will create a new repository with the oldest folder, and then sequentially & automatically apply all the subversion commands to transform each later folder into a new revision.

I hope that makes sense. The old shell scripter in me is tempted to try to tackle this myself, but a) I'm sure it's more work than I'd initially imagine, b) it's not the best use of my time (I'm not an expert in writing shell scripts), and c) I bet someone's already done this.

Extra Credit: have the script/tool also modify the timestamp properties, based on the folder names, so that the history in subversion was closer to reality.

I hope that all makes sense.

Thanks a lot for any help.

P.S. I'd prefer to do this all under Linux, but if there is a (gasp!) Windows solution, beggars can't be choosers, can they?

+3  A: 

I think the shell script solution would not be too hard. Something like this:

for d in 200*
do
    cp -a $d/* svndir/
    cd svndir
    svn add *
    svn commit
    cd ..
done

Rather naive code I know, but I would think that something a bit like this would do the job (subject to there already being a repository checked out into svndir). Presumably there is an argument to svn commit which skips the requirement to enter comments, otherwise this would be pretty tedious.

cp -a will retain timestamps but of course the svn history will show everything being committed on the current date. Perhaps you could use the 'date' command to actually set the server date according to the directory name (value of $d) each time you copy and commit. However that might be a bit over the top.

Leigh Caldwell
You could pass --message "Commit version from $d" --non-interactive to svn commit. This adds a commit message and prevents any interactive questions.
Simon Lehmann
This won't delete files that get deleted.
wnoise
Dan
+2  A: 

For this use case the load-dirs.pl was created, it takes your directories and will import them into Subversion and can also maintain version history for renames and deletes. A good documentation is available inside the subversion repository(link above)

Peter Parker
Thanks very much, I'll give it a whirl. Appreciate the help.
Dan