How do I SVN copy files or projects in Subclipse? - eclipse

I am working with Java projects in Eclipse (Juno), using Subclipse for version control.
I've noticed that when I copy a file or a project, the resulting copy will not be under version control.
I can add the files to version control as a second step, but that will break their Subversion history.
Usually, I want to preserve the history: I want a way to copy files and projects in Eclipse that will issue a svn copy command.
How can I achieve this?
Update: I tried it on a project again; it seems that a svn cp was issued.
In which case my question becomes: how can I disable that?

Whenever I want to make a copy of code I use the branch feature, this would keep the history intact. It is available under (Right-Click on resource) -> Team -> Branch/Tag.

Related

Can I recover the replaced file by SVN in eclipse

I am using SVN as code repository. Accidentally I replaced my entire project with the one in SVN. As soon as I replaced, i tried to look at the local history of some files and figured out that there won't be any.
Is there anyway I can switch back my project (or atleast a file in that project) to previous versions in eclipse?
History is stored in this (hidden) folder:
.metadata/.plugins/org.eclipse.core.resources/.history/
So you should be able to restore from there.
Use the svn history. In Eclipse IDE (with subeclipse):
right click
show history
in the history window, locate the desired version (e.g. 55)
right click on it and Switch to Revision 55

Using Subversion in Spring Tool Suite: untrack file committed by accident

Does anyone know how I can untrack a couple of files committed by accident?
I'm looking for the equivalent of the Mercurial hg forget command.
I'd especially appreciate any answers that explain how to untrack files using the Spring Tool Suite IDE, i.e. not from command line.
It seems that it is not as easy as in Mercurial :) especially if the repo is shared with others and they also need to keep this file (after it is removed from tracking and ignored, the first svn update will delete it).
See this answer for detailed instructions: SVN: Ignoring an already committed file
I found a way to achieve this by fiddling around. Neither of these is ideal - can anyone improve on this?
Option 1: Delete in SVN repository, then resolve
Navigate to Window -> Open Perspective -> SVN Repository Exploring
to view the repository.
Right-click on the file and press Delete...
Navigate back to Spring perspective
Right-click on the file and press Team -> Show Tree Conflicts
In SVN Tree Conflicts perspective, right-click and press Resolve... to explicitly accept the repository deletion
In Spring perspective, right-click on the file and press Team -> Add to svn:ignore
Option 2: Delete locally, then resolve
Move file somewhere else on local
Commit to repository
Copy file back into tracked project
Add to svn:ignore
Run svn delete <path> --keep-local in your working and then svn commit the change.
The first command will schedule the delete of the file in repository, however it won't touch it in your working copy making the file unversioned. You can add the file to ignores afterwards.
svn delete
--keep-local

Eclipse Kepler with Subclipse not picking up newly added files

my Mac is running:
Mavericks 10.9.3
subversion 1.8.9
subversion-javahlbindings 1.8.9
Eclipse Kepler SR2 with Subclipse 1.10
For some reason, when I'm working on a Project and go to Team > Commit
Subclipse will detect changes in existing files and allow me to commit, but it doesn't list added files.
In order to commit added files I have to use Team > Synchronise with Repository > Right-click on file tree > Commit
In the previous versions of svn/subclipse, added files were automatically picked up, and got committed straight from the Team > Commit dialog.
I've tried configuring Subclipse to use each oif the JavaHL and SVNKit options, but neither picks up newly added files.
Can anyone suggest what might be wrong?
In svn, new files must be explicitly added (using the svn add command) before they can be committed. Eclipse's Synchronize view does that for you, since it has shown you the files that need to be added and it presumes that you "approve" of the new ones. But using the Commit command directly is just calling svn commit without svn add, so the new files are not included.
When you create new files with other editor or copy/paste in finder, some times SVN doesn't detect.
You can try refresh the Eclipse project, just click in your project select "Team -> Refresh/Cleanup" from context menu, then the files will appear in Team Synchronizing View.
Works for me.

How to remove a class that is no longer used when using SVN?

I am working on a Java project in Eclipse and I use SVN to commit various versions of it in the repository. However I have noticed, that when I delete a class and I then commit the project, the old class is still included in the latest committed version of the project. Is there any way to prevent the SVN from maintaining classes which have been actually deleted?
Update: The same problem comes out when I rename a class and then I try to commit the new version of the project. It keeps both classes and stores both on the repository version. How can I prevent it from storing the old ones? I appreciate deeply any help bacause I would not like in any case to store it spoiled with the old classes.
If you use an Subversion for Eclipse like SubClipse then deleting a file in Eclipse will automatically schedule the file for deletion on next commit.
If you use a Subversion client outside of Eclipse you will have to delete the file using that client and then refresh the project in Eclipse after the file is gone from your working copy.
You need to also delete the class in svn as well, something like:
$ svn rm path/to/class.java
You can also remove the file using Eclipse, assuming that you have the svn plugin installed. Make sure that you select the file when you are committing your changeset, otherwise the deletion won't be sent to the server.
Update: Answering the update to the question
$ svn mv path/to/OldClass.java path/to/NewClass.java
Or, as Martin mentioned, ensure that your have your subversion plugin in eclipse properly configured, then it will also do the svn rm and svn mv commands for you.
SVN needs to know about any changes for all files and folders that are controlled by SVN (i.e. that are put under version control). It is easy to detect file changes, but it is not easy to detect rename and delete operations. If you just delete a file (using your operating system tools), SVN will warn you about a missing file.
For these operations you must use the corresponding SVN commands. SVN is best learned, when doing it manually with all those SVN commands (at first).
Using a SVN client makes it a little easier for you. For example, if you use TortoiseSVN, you can right-click a file and choose "SVN delete" for doing both, deleting the file and communicate it to SVN. Same for renaming.
The same is done by using a SVN plugin in Eclipse (Subclipse or Subversive, for example). If you then use Eclipse for deleting or renaming a file, the plugin will also do the operation and communicate it to SVN.
Keep something in mind: When deleting or renaming files (and/or folders) - using SVN commands, of course - you should always do a SVN update prior to SVN commit. Otherwise you might get an error about a revision problem.

Creating eclipse project from old project

I have an old eclipse java project which is stored in SVN. I wish to create a new one based on the old one but without the SVN files. I'll be doing some experimental changes to it and I want to have the old one as backup basically. Anyone can give advice on how to do this? Thanks
FYI: This has been posted in Javaranch as well
You have a number of options:
Don't do a check-out (which creates the metadata files, allowing for changes to be easily and later committed), but an export instead. From the "SVN Repositories" view in Eclipse, right-click the project folder, then click "Export...".
Just check-out a 2nd copy of the project from SVN, naming it with a different project name in the workspace to keep it distinct. Just refrain from checking-in any changes back to the SVN repository.
Copy the project as usual, and simply delete the SVN metadata files.
Same as #3, but let Eclipse do this for you - using Team / Disconnect.