SVN: What to do if the empty folders in your working directory are deleted
Alright, I am working on a small app which recursively deletes empty directories. I have it under source control at Codeplex and I use TortoiseSVN to access it.
So, one day, I ran it on the directory where I have all my code. And it ran fine. Empty directories were gone. But then when I tried to Commit the latest changes in any of my Subversion hosted project, it just wouldn't do it! It was complaining about some missing folders or something. Apparently there are hidden folders called .svn spread around in the working directory (which I kind of knew about) which contains, among other things, very crucial empty directories (which I didn't know about). Apparently, they are so crucial that you cannot do anything when they are gone. Things just stop working...
I tried to do SVN Update, Clean up, Update to revis开发者_Python百科ion, Revert, and so on. Nothing worked. Always got error messages of some sort. Ended up having to move the folder, create a new one, get all the stuff from Codeplex again, and then manually move over my changes from the old folder. Very tedious and annoying.
So, what is going on there? Why can't it work without those empty folders? And is there any way to fix it if it happens again?
The .svn folders and their contents (even if empty) are what tells Subversion that your working copy is a working copy. Deleting them makes your directory just a directory. You could import that into the repo as you would any other new project but then you'd have duplicate projects so this is a very poor idea I think.
Better to suffer the pain of checking out a fresh working copy, copying your modified and new files into that and committing again.
I don't know enough about Subversion's implementation to tell you why it doesn't work without the empty folders, but those .svn folders hold metadata about your working copy, such as the base version of each file (so commands like svn st
can see what you have changed without contacting the server).
If you mess them up, there isn't really a good way to recover other than starting a new working copy from a clean checkout.
精彩评论