Wednesday, 11 July 2007

svn switch problem - cannot switch from ''unclean'' checkout

Is this true? svn switch will only work if switching from a clean checkout i.e. no unversioned files and no changes of any type. (I would guess a very new and simple repository might not have this problem.)

Let's see if we can find out if people know about the "svn switch problem"
Post to svn users list and also logged comment in svn bug 2505.

Subject: svn switch problem - cannot switch from ''unclean'' checkout


We had a bit of a problem with using svn switch.
If doing a switch and there are unversioned (maybe ignored) items in the checkout
then you can get errors and end up with an unusable repository.
We now keep a ''pristine'' clean checkout of any trunk or branch that is worked off of
and update it then copy and switch when we need to checkout.

I think this is this issue:

The bugs there last had activity July 2006 so I don't think they're in line to be

Do many large projects with lots of parallel development and branches use svn?
I wonder are people seeing this issue and giving up on using svn switch?
I was surprised this isn't better known? Or is it?

I think any project that made use of branches could benefit from having this
documented. A "bugfix" and better error would be nice also in time :)
It would be very nice if there was a note in FAQ or manual on svn switch.
If people agree this is an issue we could submit some content for that.
For now I'd like to hear what you think.

The switch is used at sites remote to the svn server to avoid doing a checkout
every time a developer moves to working in another branch.
Move to another branch is done frequently enough as all work is done on branches
using Trac tickets.

I think the switch problem is a puzzling one as to me it seems natural that if
an svn status reported that there were no changes to versioned files then a
svn switch would do the right thing and warn and move unversioned files out
of the way. The need to do switch only from pristine checkout is also not
mentioned in svn manual.



=== Using svn switch instead of svn checkout to save time ===

A full checkout of a large repository branch may take a long time >15 mins :(
This is a problem for users who are not in same site as svn repository.
Instead of doing a checkout every time a user may checkout the trunk (or SDB) of the
project they are working on initially. They take a copy of that clean trunk and
use ''svn switch'' to change it to the branch ticket instead of checking out the
branch ticket.

Setup (initial checkout of pristine copy):
  mkdir /pristine
  cd /pristine
  svn co $SVNROOT/${project}/trunk ${project}_trunk
  gtar -zcvf ${project}_trunk.tgz ${project}_trunk

Switch (user updates pristine copy from svn, then copies it and does the switch):
  # '''Note: It is very important that the pristine copy is kept absolutely clean'''
  cd /pristine/${project}_trunk
  svn up
  cd ..
  gtar -zcvf ${project}_trunk.tgz ${project}_trunk
  cd /checkedout
  gtar -zxvf /pristine/${project}_trunk.tgz ${project}-xxx
  svn switch $SVNROOT/${project}/branches/ticket-xxx

==== support scripts and Pristine server ====

A server can be set up in each site which will keep
''pristine'' clean copies of project trunks and SDBs. The copies would be
checked out afresh once and updated nightly. (by script setup as a service)

Users on a site would use those ''pristine'' clean copies to switch from and
this would be supported by a script. A script to clear out and make ''pristine'' a checkout  is left
as an exercise to the student :-P :)

Switch from pristine: (recordings share must be mounted)
  cd /checkedout
  gtar -zxvf $SVNPRISTINE/${project}_trunk.tgz ${project}-xxx
  svn switch $SVNROOT/${project}/branches/ticket-xxx

No comments: