Thursday, January 10, 2008

Playing with svn delete and svn status

I was playing around with svn recently while working on story related to svn delete. We are doing a physical delete of a folder in code and then svn delete from powershell script. But somehow svn delete doesn't work and the deleted folder comes back again on svn update.

I found out that if we delete the folder (or file) physically from the file system and then do a svn delete for that folder, it doesn't get deleted from the svn and comes back on svn update and this was the cause of my problem. However, if we do svn delete directly, the folder gets deleted properly and doesnt come back on next update. Obviously, the folder comes back on svn revert as we haven't committed yet.

I tried to figure out if I can do something else rather changing the code to do svn delete. I tried to do svn commit in the script after doing svn delete. However, commit also commits other changes apart from deletions. When I tried to do commit by specifing folder name like -

svn commit $matches["file"] -m $comment

then it gives error -

svn: Commit failed (details follow):
svn: Entry for 'C:/foo' has no URL

This is not unexpected. This happens because the folder is not present in the given path
as it is already deleted. So, I was not able to do commit just for the deletion.

Finally, we changed the code to do the svn delete at first place rather than doing physical delete. :-)


I noticed that svn status also behaves little strangly. svn stat (svn status) is supposed to give 'D' for the deleted files/folders and '!' for the files that are missing i.e. deleted without svn in the first column of status message. This works fine in most cases.

Consider this scenario- if you physically delete a folder with svn, status gives '!'. If you restore the folder and do svn delete on the same folder, it gives D in the status, which is exactly as expected.
Now, if you revert the folder and do the physical delete, you will expect that svn stat will give '!' as usual, but this time, svn status gives 'D' !

It seems that the svn remembers that delete was invoked on the folder and gives D even if it's a file system delete. And now onwards, the svn will keep on giving 'D' in the status for that folder even if you do physical delete or svn delete. This behaviour caused some confusion. Is it a svn bug ?

No comments: