views:

159

answers:

2

(I don't really care if it's my fault but rather why things are happening, of course...)

I have a rails site in SVN on a remote server. On my local copy I do a switch (svn switch http://whatever/branch .), and then things are totally bizarre and the site doesn't work. I finally track it down and it turns out that part of the build (particularly, the app/config directory) is pointing to the wrong branch. Please note:

  • I never switch using anything other than the SVN command line
  • I only switch at the root of the installation
  • I always switch as root (sudo -s) and I'm sure that the permissions were set correctly on the whole tree (chmod -R 777)

Any ideas on how part of the working directory could end up pointing to the wrong place? In my memory, this is not the first time that some sub of the working directory is pointing to the wrong place... why would this happen?

A: 

Excuse me if you know what you're doing, but it sounds like you aren't. (Or the question isn't clear). If you include the results of svn status from the relevant directories, we could get farther.

svn switch

(svn help switch)

is for switching repositories, which shouldn't part of a common workflow.

jskulski
Switching a working copy of trunk to a branch is a valid and common use of svn switch: http://svnbook.red-bean.com/en/1.0/ch04s05.html
Anthony Cramp
Ah, thank you. I hadn't used it like that.
jskulski
+7  A: 

There is a whole section about switch problems in the official Subversion FAQ. It says:

In some cases where there are unversioned (and maybe ignored) items in the working copy, svn switch can get an error. The switch stops, leaving the working copy half-switched.

Their advice is to only switch from a clean working copy.

Another thing is Mixed Revision Working Copies.

Basically this means that the files in your working copy can be (and normally are) from different revisions.

Here is what the SVN Red Book has to say about this (emphasis by me):

For example, suppose you have a working copy entirely at revision 10. You edit the file foo.html and then perform an svn commit, which creates revision 15 in the repository. After the commit succeeds, many new users would expect the working copy to be entirely at revision 15, but that's not the case! Any number of changes might have happened in the repository between revisions 10 and 15. The client knows nothing of those changes in the repository, since you haven't yet run svn update, and svn commit doesn't pull down new changes. If, on the other hand, svn commit were to automatically download the newest changes, then it would be possible to set the entire working copy to revision 15—but then we'd be breaking the fundamental rule of “push” and “pull” remaining separate actions. Therefore the only safe thing the Subversion client can do is mark the one file—foo.html—as being at revision 15. The rest of the working copy remains at revision 10. Only by running svn update can the latest changes be downloaded, and the whole working copy be marked as revision 15.

Ludwig Weinzierl
Thanks a lot Ludwig. While I didn't know about the second case, it doesn't matter since SVN forces you to update before you commit items that need it. The first case, though, is brilliant: "the switch stops, leaving the working copy half-switched." That is what I think happened. Great to know, thanks again.
Yar
And this is why everyone now uses Git. You can actually honest to goodness branch without wanting to kill yourself.
Ian Terrell
@Ian Terrell: so how does Git handle a switch between branches when unversioned files happen to be obstructing versioned ones? Overwrite them?
Wim Coenen