PDA

View Full Version : Subversion and delete action


John Kerr
07-23-2007, 05:08 PM
I am having an issue with the delete action and my working copies from a Subversion repository. It appears that if I create a VBP script that uses the Delete Files action on anything within my Subversion working copy then folders that do not match the specified file\folder in the delete action get deleted from the .svn folder causing any further repository actions to fail.
The delete action can be specific to a file or folder name or can use wild cards...doesn't matter. Folders get deleted from the .svn folder.
There are no references to files or folders in the .svn directory being deleted when the action is run. I have tried to exclude the .svn folder and also explicitly the folders that are getting deleted in the .svn folder and no luck.
It makes me very nervous that VBP is not accurately telling me what it is deleting when using the delete action and worse yet that it is deleting folder and files that are no specified in the delete action.
The folder names in the .svn directory that get deleted are "props" and "tmp".

kinook
07-23-2007, 05:44 PM
The Delete Files action will log all files it deletes as long as 'Log files that are deleted' option is checked. You can also see which files it will delete (without deleting them) by checking the 'Do not delete, only display files that would be deleted' option and rebuilding the step.

I've attached a sample that creates files/folders as described and then deletes, excluding props and tmp folders, and it works as expected here:

7/23/2007 4:42:38 PM: Building project step 'Create files/folders'...
7/23/2007 4:42:38 PM: Building project step 'Clean'...
Folder 'C:\Temp\VBP_Del_test\.svn' does not exist, not deleting
7/23/2007 4:42:38 PM: Building project step 'Create file'...
Creating file C:\Temp\VBP_Del_test\.svn\props\test.txt
7/23/2007 4:42:38 PM: Building project step 'Create file'...
Creating file C:\Temp\VBP_Del_test\.svn\tmp\test.txt
7/23/2007 4:42:38 PM: Building project step 'Create file'...
Creating file C:\Temp\VBP_Del_test\.svn\test.txt
7/23/2007 4:42:38 PM: Building project step 'Create file'...
Creating file C:\Temp\VBP_Del_test\.svn\abc\test.txt
7/23/2007 4:42:38 PM: Building project step 'Dir before delete'...

Directory of C:\Temp\VBP_Del_test\.svn

07/23/2007 04:42:38 PM 4 test.txt
1 File(s) 4 bytes

Directory of C:\Temp\VBP_Del_test\.svn\abc

07/23/2007 04:42:38 PM 4 test.txt
1 File(s) 4 bytes

Directory of C:\Temp\VBP_Del_test\.svn\props

07/23/2007 04:42:38 PM 4 test.txt
1 File(s) 4 bytes

Directory of C:\Temp\VBP_Del_test\.svn\tmp

07/23/2007 04:42:38 PM 4 test.txt
1 File(s) 4 bytes

Total Files Listed:
4 File(s) 16 bytes
7/23/2007 4:42:38 PM: Building project step 'Delete Files'...
Delete files in folder 'C:\Temp\VBP_Del_test\.svn\'...
test.txt
abc\test.txt
2 file(s) deleted
7/23/2007 4:42:38 PM: Building project step 'Dir after delete'...

Directory of C:\Temp\VBP_Del_test\.svn\props

07/23/2007 04:42:38 PM 4 test.txt
1 File(s) 4 bytes

Directory of C:\Temp\VBP_Del_test\.svn\tmp

07/23/2007 04:42:38 PM 4 test.txt
1 File(s) 4 bytes

Total Files Listed:
2 File(s) 8 bytes
7/23/2007 4:42:38 PM: Build successfully completed.


Please ZIP and send or post:
1) The info from Help | About | Install Info
2) The .bld file
3) A build log file

Thanks.

John Kerr
07-23-2007, 06:20 PM
I ran your script and of course had no issues. I then created a similar script that instead of working with created files and folders, it retrieves files from a test repository, lists them, explicitly deletes a file named "Copy of file.txt", lists again and then tries to update the working copy from the repository.
What i noticed is that the entire contents of the subversion directory (.svn) that comes with the repository get command is not being listed. The logged output does not show the folders or the contents of the folders tmp and props. I put in a stop to verify and the folders are located within the .svn folder and have folders contained in them for the repository to use. After the delete is run, the deletion of those files is not logged to output and they no longer exist in the test area. Consequently, the final update from the repository fails because the necessary files needed to talk to the repository are no longer in the .svn folder.

I checked the box in the delete action to not delete but log what would have been deleted and it shows what I would expect with no mention of the items in the .svn folder. If I uncheck that option and run again, the files are deleted.

kinook
07-24-2007, 07:30 AM
Again, I'm quite sure the Delete Files action will log every file it deletes if 'Log files that are deleted' is checked. But I'm not sure if the problem you're experiencing is with folders or files (or both). The Delete Files action does have an option to delete empty folders, but that option also honors exclusions. Also note that the List Files action doesn't list empty folders (you didn't provide a sample or much detail, so I'm not sure how you're listing the files/folders).

I've attached another .bld file (and log) that performs a svn checkout step (using VBP 6.4 and Subversion 1.4.3 on Win XP SP2), which does create some hidden .svn folders, each with prop-base, props, text-base, and tmp subfolders (as well as 4 files named all-wcprops, dir-prop-base, entries, and format -- perhaps these are needed for proper svn operation?), but props is just an empty folder and tmp contains 3 empty subfolders (prop-base, props, text-base).

The Delete Files step following that is identical to the one from the earlier sample (but with a folder of '%BASE_DIR%\SVN_Source'), and it does, as expected, delete the files in the .svn folder, but not the props or tmp subfolders. At this point, building the checkout step again does fail ("Can't create directory 'doc\.svn': Cannot create a file when that file already exists"), so some files/folders it needs may have been deleted, but the Delete Files action appears to be deleting only what it was told to (I'm not familiar enough with svn to know what should or shouldn't be deleted, if anything).

Please ZIP and send or post:
1) The info from Help | About | Install Info
2) The version of Subversion being used
3) A .bld file that demonstrates the problem
4) A build log file

Thanks.

John Kerr
07-25-2007, 10:25 AM
Thank you for your patience and sorry for the lack of info. I believe that I got it now. You're right that the directories in question are empty. When performing an action on a version controlled directory subversion depends upon those empty directories in the .svn folder to be there or the actions, be it update, commit, whatever, will fail.
Now, I didn't realize that the list files will exclude empty directories. I don't understand the necessity of that but that is besides the point.
After tooling around with the issue some more I realized that what is happening is that when the option to delete empty folders is checked it in fact does not honor exclusions. I can work around these issues now that I understand the problem.
Thank you for your assistance.

kinook
07-25-2007, 11:06 AM
Originally posted by John Kerr
Thank you for your patience and sorry for the lack of info. I believe that I got it now. You're right that the directories in question are empty. When performing an action on a version controlled directory subversion depends upon those empty directories in the .svn folder to be there or the actions, be it update, commit, whatever, will fail.
Now, I didn't realize that the list files will exclude empty directories. I don't understand the necessity of that but that is besides the point.
It's the List Files action--it only lists folders containing matching files (to show what folder the listed files are in). We'll consider adding an option to also log empty folders.

After tooling around with the issue some more I realized that what is happening is that when the option to delete empty folders is checked it in fact does not honor exclusions. I can work around these issues now that I understand the problem.
I checked the 'Delete empty folders' in the sample above, and the empty tmp and props folders were not deleted.

kinook
08-12-2009, 02:15 PM
In VBP v7, the List Files action includes an option to list empty folders (Files tab).

http://www.kinook.com/Forum/showthread.php?threadid=3884