tags:

views:

601

answers:

2

Hi,
we have a template project we often copy. so we can costumize the copy and still have a common template.

To optimize the "copy & initial changes"-process, i though that i can write a little script, that does the following:

  • copy the project-template (in svn) to another directory in the svn
  • check-out the project and do some changes (change names in some files)
  • check-in the customized project

The question is: what's the best way to do this? any experience in this? which type of script (normal batch or java)? any example code?

thanks for your answers

A: 

Just a shell script would do.

Sietse
A: 

Here is something i put together with some information i found here.

#!/bin/bash


searchterm="<ProjectName>"
replaceterm="New Project"
srcsvnrepo="file:///svnrepoaddress"
destsvnrepo="file:///data/newrepo"
dumpfile="/home/<user>/repo.dump"
tmpfolder="/home/<user>/tmp_repo"

svnadmin dump $srcsvnrepo > $dumpfile
svnadmin create --fs-type fsfs $destsvnrepo
svnadmin load $destsvnrepo < $dumpfile
svn co $destsvnrepo $tmpfolder

for file in $(grep -l -R $searchterm $tmpfolder)
  do
    sed -e "s/$searchterm/$replaceterm/ig" $file > /tmp/tempfile.tmp
    mv /tmp/tempfile.tmp $file
    echo "Modified: " $file
  done

svn ci $tmpfolder --message "Initial Check-In"

Basically this will dump a backup of the specified source svn repo to a file, create a new repo, load the backup into it, check out the files, get a list of files that contain the string to search for, perform a regex on each of those files storing the new version in a temp location and then moving the temp file back to the original location, and finally checking the changes back into the new repo.

I haven't fully tested this so some minor tweaking may be necessary, but the basic steps should be correct. Please let me know if i've made some gross miscalculation and this totally does not work.

Jason Miesionczek
this is overkill for what the original poster wants to do. in his case a simple svn copy + svn co +svn ci should be enough
Jean
the poster states that he wants to "check-out the project and do some changes (change names in some files)". how is what i said overkill?
Jason Miesionczek
your proposal creates an entire new repository where a branch seems to handle the use case just fine ... that is a bit overkill a simple svn copy should be sufficient.
Jean