SVN refactoring and other operations made simple (Eclipse and Subversive)

By neokrates, written on May 5, 2010

article

  • Join date: 11-30-99
  • Posts: 224
View Counter:
  • 354 views
Rate it
Ad
Poll
  • How does version control (VCS) work in your enterprise?

    View Results

    Loading ... Loading ...
Feeds:
  • bodytext bodytext bodytext

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.

Software:

✔ Eclipse Galileo

✔ 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…

IMPORTANT:
  1. In this article, Eclipse SVN repositories view is used. So, most commands and paths are related to this view.
  2. You should always comment the changes you make. That will make it easier to understand what was moved, why, etc…

1

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.

2

Create branches, tags. Server-side way

You want to branch or tag svn://my.svn.sever/trunk/project.

2.1

Get repository source ready

Make sure all is checked in under svn://my.svn.sever/trunk/project.

2.2

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.

2.3

“Copy 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. ;-)

2.4

Done

Communicate and unlock if you need to.

3

Create svn server-side directory tree

Maybe you want three paths under the trunk:
/trunk/serverside/tomcat
/trunk/serverside/jetty
/trunk/serverside/glassfish

To do that, in SVN Repositories view click with right mouse button on trunk and then select new->folder.
Enter /trunk/serverside/tomcat.

Then repeat the process for /trunk/serverside/jetty and /trunk/serverside/glassfish

4

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

4.1

Disconnect

In Navigator view use team->disconnect (Also delete svn information).

4.2

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.

4.3

Reconnect

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.

Done.

5

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.

6

Copy, cut and paste

You dropped your jetty project under /trunk/serverside/tomcat. Easy to fix it.

In SVN repositories view:

  1. select project->right mouse button->cut
  2. select path your want you project to be under (In our example /trunk/serverside/jetty)
  3. right mouse button->paste

7

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:

  1. 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

8

Mass checkout

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.

Be Sociable, Share!
 

LEARN MORE (amazon bookstore)

TAGS

SOCIAL
Be Sociable, Share!


Leave a Reply