tags:

views:

89

answers:

4

I am trying to automate the process of creating new projects from existing projects using scripts. My initial idea is that there should be two scripts:

1: check out an existing project from the svn repository and then rename it (i.e. search and replace from ExistingProjectName => NewProjectName in all files, then "svn rename" all files and directories containing the string ExistingProjectName)

2: after the user has checked the compilation, etc., create the new project on the repository (e.g. using the "svn switch" command)

The idea was that the repository should not be altered until the user has had a chance to carry out checks.

However, a potential risk has been pointed out to me. After #1 is run, the local working copy is still associated with the existing project. Somebody who carelessly commits at this stage will mess up the existing project.

Can anybody think of some svn tricks which can stop the user committing after #1? I cannot think of anything even after going through the documentation.

Thank you.

Andy

(If it is not possible to stop the committing, then we will need to go with the lesser of two evils, and write the script so that it will update the repository before the user has a chance to check.)

A: 

Possibly, you could write a special value to the altered files, to indicate the state. Then, use an svn commit hook to check whether someone is trying to commit to the wrong repository...

abyx
+1  A: 

probably you may want to do an svn export.

Josh
Unfortunately if you use svn export, you will not get all the history for the project. svn would effectively be treating it as a brand new project (information about all the changes in the old project will not be present) when you commit.
Andy
A: 

The trick to stop the committing is to use svn export in the first step. Then when the changes ar ready, use svn import.

Don
Unfortunately if you use svn export, you will not get all the history for the project. svn would effectively be treating it as a brand new project (information about all the changes in the old project will not be present) when you commit.
Andy
+1  A: 

To create a new branch in svn, you use the svn copy command. Once that's finished you have 2 projects in the repository and you can modify either of them at your leisure.

So, if you're going to svn rename the project anyway - why not make the branch and then rename the files (and update the contents). Job done!

The alternative would be to check out your existing project, rename and edit it, then add the working copy to svn. That would be 'atomic', and would prevent the rename from showing up in the log.

Adding a brand new branch is just as good as copying, except you do not get the benefit of svn's 'cheap copies', however as you're making significant edits (and renames!) wouldn't this be a better approach in the first place?

gbjbaanb
The script can only be described as "atomic" if it removes your working copy when it fails to compile (i.e. after checking out and renaming). If the working copy remains, then the user can still commit and mess up the project. On the other hand, the user might want to debug so removing the working copy will not be popular!Starting with a copy in the repository to create two projects is the solution we are arriving at as well. The more I think about it, the more I am convinced that it is the least of all devils.
Andy
If the process fails, delete the branch from the server. The working copy doesn't have to be deleted because an attempt to check it in will fail because the branch no longer exists.
Don