Professional Subversion Hosting
Free SVN Hosting, SSL, ACLs, Petabyte Storage | |||||||||||||||||||||||||||||||||||||||||||||
|
The svn switch command transforms an
existing working copy to reflect a different branch. While this
command isn't strictly necessary for working with branches, it
provides a nice shortcut. In our earlier example,
after creating your private branch, you checked out a fresh
working copy of the new repository directory. Instead, you can
simply ask Subversion to change your working copy of
$ cd calc $ svn info | grep URL URL: http://svn.example.com/repos/calc/trunk $ svn switch http://svn.example.com/repos/calc/branches/my-calc-branch U integer.c U button.c U Makefile Updated to revision 341. $ svn info | grep URL URL: http://svn.example.com/repos/calc/branches/my-calc-branch After вswitchingв to the branch, your working copy is no different than what you would get from doing a fresh checkout of the directory. And it's usually more efficient to use this command, because often branches only differ by a small degree. The server sends only the minimal set of changes necessary to make your working copy reflect the branch directory. The svn switch command also takes a
Of course, most projects are more complicated than our
In other words, if a user knows that the branch-work only needs to happen on a specific subdirectory, they use svn switch to move only that subdirectory to the branch. (Or sometimes users will switch just a single working file to the branch!) That way, they can continue to receive normal вtrunkв updates to most of their working copy, but the switched portions will remain immune (unless someone commits a change to their branch). This feature adds a whole new dimension to the concept of a вmixed working copyввnot only can working copies contain a mixture of working revisions, but a mixture of repository locations as well. If your working copy contains a number of switched subtrees from different repository locations, it continues to function as normal. When you update, you'll receive patches to each subtree as appropriate. When you commit, your local changes will still be applied as a single, atomic change to the repository. Note that while it's okay for your working copy to reflect a mixture of repository locations, these locations must all be within the same repository. Subversion repositories aren't yet able to communicate with one another; that's a feature planned for the future. [24] Because svn switch is essentially a variant of svn update, it shares the same behaviors; any local modifications in your working copy are preserved when new data arrives from the repository. This allows you to perform all sorts of clever tricks. For example, suppose you have a working copy of
[24] You can, however, use svn
switch with the | All Plans Include
| ||||||||||||||||||||||||||||||||||||||||||||