Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN Switch is not deleting the folders / files in the working which is not present while switching to tag or branch

I have a requirement to make a build based on the tag or branch. So I have automated my build process to do switch to a tag or branch whenever they are asking for the Builds. Iam using svn switch command to make the working copy point to tag or branch from trunk working copy. The problem is: If there are newly added folders present in the head revision, they are not getting deleted from the working copy. They remain as unversioned in the working copy, but the unversioned folders in the build causing lot of problems. How to avoid this problem? Is there any option to avoid unversioned files while using svn switch command.

like image 534
sandy Avatar asked Feb 03 '11 09:02

sandy


People also ask

What does svn Switch do?

A switch moves your working copy through time and space. Because svn switch is essentially a variant of svn update, it shares the same behaviors; any local modifications in your working copy are preserved when new data arrives from the repository.

How do I permanently delete files from svn?

To remove a file from a Subversion repository, change to the directory with its working copy and run the following command: svn delete file… Similarly, to remove a directory and all files that are in it, type: svn delete directory…

Does svn Switch preserve local changes?

Use the "svn switch" command to convert your local "trunk" copy into a copy of this new branch. Your local changes will be preserved. If you receive any alerts about conflicts, be sure to select "mine-conflict" to keep your changes.

How do I delete a working copy in svn?

If you have a working copy which you no longer need, how do you get rid of it cleanly? Easy - just delete it in Windows Explorer! Working copies are private local entities, and they are self-contained. Deleting a working copy in Windows Explorer does not affect the data in the repository at all.


1 Answers

there's no bug but you have to make sure that the workspace is really clean before switching. If it is clean, switching deletes/creates files and dirs that are present in only one version. To this end the subversion 1.6 manual says:

“Switching” a working copy that has no local modifications to a different branch results in the working copy looking just as it would if you'd done a fresh checkout of the directory.

I just tested this with a newly created test repository. If on the other hand there are local modifications in the current workspace, svn won't discard them. svn is pretty conservative with this respect. E.g. I created a directory dir on trunk and committed it. Then I created a backup file dir/file.~1~. It wasn't reported by svn st because *~ is globally ignored with my config. When I switched back to a branch svn should have deleted dir but this would have deleted the backup file, so svn didn't do that. It kept the directory as a local modification.

side note: when switching forth to trunk again svn reported an error because dir as local modification on the branch was in conflict with the versioned dir on trunk. --force solved that problem.

like image 145
user829755 Avatar answered Oct 13 '22 04:10

user829755