SVN refactoring and other operations made simple (Eclipse and Subversive)By neokrates, written on May 5, 2010
Many things go easier with svn, if you use Subversive as refactoring tool. Here is how.
There are many ways to work with subversion in Eclipse. Some will cost you time and are more error prone. More operations you do, more dialogs you go through, more errors will occur.
Subversive (Svn Kit 1.6)
Should also work for:
May work with other Subversive versions
Most compatible Eclipse versions
Most operations on subversion server can be done in easy, elegant way…
- In this article, Eclipse SVN repositories view is used. So, most commands and paths are related to this view.
- You should always comment the changes you make. That will make it easier to understand what was moved, why, etc…
Create branches, tags. Client-side way
The easiest way to branch or tag with Subversive is to use team->branch and team->tag. Use it always if you can.
But there are often one of two problems with such easy way:
- you project layout is different in the way which Subversive doesn’t understand;
- you need to branch/tag many project at once, checkout may be slow or just one extra operation you don’t need.
In that case, here is another simple way.
Create branches, tags. Server-side way
You want to branch or tag svn://my.svn.sever/trunk/project.
Get repository source ready
Make sure all is checked in under svn://my.svn.sever/trunk/project.
No changes for 1 minute
If you have a group of developers, notify them that you branch or tag. Lock the path if you need to.
- Open svn://my.svn.sever/trunk/project in SVN repositories view.
- Click on project with the right mouse button and choose “refactor->copy to”.
- Open the target path (in my case I want to tag, so I open: svn://my.svn.sever/tags.
- Add tag/branch name and project name. Normally there is a naming scheme to be followed. We use /branches/project_name/branch_name scheme.
- So, I enter: project/MILESTONE_05052010 .
- Important if path doesn’t exist, it will be automatically created.
- Don’t forget a nice comment.
Communicate and unlock if you need to.
Create svn server-side directory tree
Maybe you want three paths under the trunk:
To do that, in SVN Repositories view click with right mouse button on trunk and then select new->folder.
Then repeat the process for /trunk/serverside/jetty and /trunk/serverside/glassfish
Move and reconnect
Maybe svn://my.svn.sever/trunk/project is just the wrong place for the project. There is some category you want your project to belong to. Say, it belongs to serverside/tomcat category.
What you want is to relocate it to svn://my.svn.sever/trunk/serverside/tomcat/project
In Navigator view use team->disconnect (Also delete svn information).
Move the project
In 1 and 2 use cases I have shown how to use copy to and new folder to create server-side svn tree. Here instead of copy to move to is used. Apart from that, 1 and 2 use cases apply.
Just use move to the way copy to is used.
By now you have the server side path svn://my.svn.sever/trunk/serverside/tomcat/project and project is there.
- Copy the path to the clipboard (right mouse button on the project, copy url)
- Now, in Navigator view, select the project and select team->share project.
- Select the repository.
- In the “select the project(s) location, paste the URL: from clipboard”
- Finish, answer “Yes” to the “Do you wish to proceed?” question.
- Now you might be presented with the window which allows you to synchronize. That doesn’t happen every time. You also can choose to cance i.e. do synchronization later.
Refresh subtree to see your changes
For sometime now, refresh was a bad feature to use. With Subversive (Svn Kit 1.6) it works great. So, after refactoring you can always select the root path (under which structure you changed something) click with right mouse button and select refresh.
Copy, cut and paste
You dropped your jetty project under /trunk/serverside/tomcat. Easy to fix it.
In SVN repositories view:
- select project->right mouse button->cut
- select path your want you project to be under (In our example /trunk/serverside/jetty)
- right mouse button->paste
Check out as instead of import
If you use Navigator Import command, you will go through many steps until you are done. Also, for the import of the second project, you will go the very same way once again. Shortcut would be nice!
In SVN repostories view:
- select project->right mouse button->check out
Remark : Make sure there is no project with the same name in your workspace. Or subversive checkout will ask you for new name.
Alternatively, use Find/Check Out As
Same as in use case 6. In SVN repostories view:
Just select all paths you want to checkout. Better would be they have no name conflicts with existing projects and with each other. That way, all projects will check out without complains.
LEARN MORE (amazon bookstore)
INCOMING SEARCH TERMS