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

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

Related

How do I SVN copy files or projects in Subclipse?

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.

Subclipse SVN first commit ignore certain directories

Decided to take the jump from CVS to SVN.
I setup a new repository in subclipse for my project. When I go to 'Finish' the setup it wants to do an initial commit and presents me with a flat list of files to select the files for version controlling.
The problem is I have thousands of generated binary files I dont want to commit.
So I click on cancel because it would take me all day to go through and unselect all the unwanted files. Annoyingly when I click on a parent category for the files I want to ignore it is not recursive!
So I click cancel then go to the eclipse directory structure for the project and manually set svn:ignore on all directories I want to ignore. Then I try and do a commit again and all the files are once again presented - ignore seems to have done nothing.
Can anybody point out what I might be doing wrong?
For the first commit, I recommend writing a small script to delete (of course you'll have a backup) all the files that are not meant to be committed.
Afterwards, if you find you accidentally committed a file, you can
svn delete file
Upon the first checkout, copy back (or better yet, regenerate) all the binary files. This will trigger svn to notice that your local repository is out-of-sync with the remote repository.
cd <Root of local repository>
svn status
You will see lots of "to be added" items. Go to the parent directory and add in svn:ignore properties for each of the generated items.
cd build
svn propedit svn:ignore .
which will open an editor (if it doesn't, you need to set the environmental variable SVN_EDITOR to a suitable editor). Then you can add in entries that svn will know are not tracked.
(in the ignore property editor)
target
build
image*
*.o
(and so on)
Save the file, and it will be staged for the next commit. Subsequent runs of svn status will no longer show these files as "needing to be added", but they will show the directory as "needing to be committed (it's a revision on the directory)"
Quick Aside
So I'm not entirely certain exactly which functionality of Subclipse you were using in order to create a repo and share a project to it, I'm assuming you created like a file based repo through the eclipse SVN repo view and tried to share and then commit to it. It looks like your problem got solved but I did want to add an answer on here because I ran across this post looking for the answer to this same problem of handling initial commits even just in general with SVN and wanted to offer help to anyone else looking for the help.
Intro
To start off I would recommend not working through an IDE extension like this just for the initial commit as they can miss a lot of the options for handling opening a repo in SVN. I personally really like the command line form of SVN to work with but TortoiseSVN is a good option for a GUI.
Whether you create a local file-based repo or are connecting to an SVN server and you want better control over your first commit in an previously unversioned project here is what I've found as the best general workflow for doing so.
Create the remote folder to save to.
On command line this will be:
$> svn mkdir your-url-scheme://your-site-address.domain/path/to/repo/example-directory
Or on TortoiseSVN open your repo for browsing, right click, and select "create new folder"
This will give you a location in the SVN repo to checkout from for our next step.
Checkout in to the already started project
Make sure to use the empty, newly created folder in your repo to checkout with. SVN does not actually require a folder being checked out to to be empty, which is an important part of what makes it actually very flexible and able to subsume parts of your directory into it fairly easily if used correctly.
Now you will checkout this empty folder into the root folder of your already started project. This will add your project to the working copy of this folder without any commit being made yet. The command is:
$> svn co your-url-scheme://your-site-address.domain/path/to/repo/example-directory /your/projects/root/
"co" standing for checkout. In Tortoise svn you can right click on or in the empty repo folder and select "checkout..." and then select the project root.
Set ignores and commit
Finally, you can easily set your ignores on certain files before adding any other files to the tree using the command:
$> svn propset svn:ignore file-or-directory-to-ignore
And to add all non-ignored directories and files:
$> svn add * --force
The force is technically unnecessary in this case but ensures full recursion. You can also now do all of this in your file explorer if using TortoiseSVN or you can even use your IDE extensions to do this at this point(make sure to ignore all files you need to before mass-adding files for commit), all that's left is to make sure to commit the newly added files to the repo and you're up and running with source control :)
Added this method here simply because this method allows you to avoid any unnecessary copying of those stinky binaries that no one wants to lug around with them.

Eclipse subsersive - delete a file but keep it locally

my question is in the title. How can I delete a file from the repository but
keeping it locally ? In other words, an eclipse subsersive equivalent to the
"svn --keep-local" command line
When I right-click on my file, the only Delete item I can found is even
not in the TEAM menu but in the general file menu. By deleting it, it will be removed from the repository at the next commit BUT also locally.
any idea ?
thank you very much
Eric Pellegrini
Open the SVN Repository Exploring perspective.
Using either the SVN Repositories or SVN Repository Browser view, navigate to the file you want to delete.
Right-click and select Delete...
This will delete the file in the repository, but will keep the local copy intact.

SVN Merge conflict during commit

Eclipse + Subversive plugin
On commiting a directory which is out of sync with the SVN a message pops up:
Merge conflict during commit
svn: Commit failed (details follow):
svn: File or directory '.' is out of date; try updating
svn: resource out of date; try updating
Tried to update the whole project from Eclipse Navigator view (right click>Refresh or F5) and the problem still persists.
Is there something that can be done in this case?
You are mixing up two different operation in Eclipse:
Update (from version control)
and
Refresh
"update" means retrieve the most recent version of a file(s) from the version control system. "Refresh" just means that Eclipse will update its view of the local filesystem, in case a file was changed outside Eclipse.
You need to do an update (Team->Update).
You should update, resolve conflicts, then commit again.
See this link for help on resolving conflicts in eclipse.
Sometimes eclipse+subversion gets a bit lost and a more robust solution is called for:
Copy the code with changes to a different location (preferably via copy and paste).
Replace with latest from repo (or revert) on the directory giving the problem
Copy the changes back (via cut and paste again) and check in.
try to delete .svn/all-wcprops. maybe it will help
Someone else has modified this directory on you.
You need to do a svn update to get the latest version before commiting.
svn update
or
right click > Team > Update
Refresh or F5 will only re-read what's currently checked out and check for local changes, i.e. changes made outside of eclipse.
The svn update command pulls any changes made remotely (commits) down to your workspace.
You need to do an svn update to make sure you are completely up-to-date before committing.
svn update
If the update does not work, you may need to do a cleanup.
svn cleanup
You should be able to find both of these commands in your SVN client outside of Eclipse if you are using one.

How to undelete a file with Subversive?

Please note: This is a question about the Eclipse plugin Subversive, and not about Subversion itself. Please do not change the title to be about 'Subversion'.
So I deleted a file that I really shouldn't have.
I've found various approaches to restoring the file outside of Eclipse/Subversive, but I was wondering if there was a best/easiest-to-use/history-restoring way to restore the file using the Subversive tool.
Select the folder in the project that contained the deleted files.
Right click, select Team > Merge...
On the URL tab, set the URL to the server URL for the same folder.
In Revisions, select Revisions and enter a range that includes the deletion, e.g. 1000-1001, or use the Browse button to select them.
In Revisions, enable Reversed merge
Click Preview and check that it shows an Added entry for the files you plan to restore.
Click OK - Eclipse switches to SVN Merge in the Synchronize view.
In the Synchronize view, right click the files you want and select Accept
In the Synchronize view, use the Synchronize SVN icon to switch from SVN Merge to SVN, where you can see the restored file as an outgoing change.
If you have already submitted the remove then it's now time to roll back to the earlier version. In Subversion you do that with "svn merge", where you merge "backwards" from the current to the previous version.
Say you did this:
$ svn rm file.txt
$ svn ci -m "don't need that file"
Committed revision 1325.
Now you want to undo this and restore the old revision 1324, i.e. the state just before the remove (the dot is for 'current directory'):
$ svn merge -r1325:1324 .
If you are unsure you can do a dry-run first, where svn will print the output of the command, but not actually do anything:
$ svn --dry-run merge -r1325:1324 .
The result should indicate that the file is being added (again):
A file.txt
you could switch to revision where this file was exist. Edit/copy this file and switch back to the head revison and commit it here.
Also you could merge changes beetween two revisons - head and last revision file was exist in repository and apply changes to your working copy.
Just "Show History" on the folder, file was existing in. Then click through the history and find the lost file.
I guess you're hoping to not resort to the command line but in case it's useful as a last resort, see this question for how to do it from the command line: What's a simple way to undelete a file in subversion?
Easier: try to commit, Eclipse will show you the dialog with the changed files, click on the one you want to delete with the right button and pick "Revert".
I had a similar issue, I deleted a set of files related to a feature that after a couple of months I want to recover.
The most straightforward solution in my case was to check out in a separate directory the whole project as it was before the file were deleted.
To do this from the Eclipse Repository View go to your project, right click "Check Out As...", in the modal window write the destination folder, select a suitable date of the past in which the deleted file existed (weird, my plugin does not give the possibility to choose a given revision..) and check out.
Now you can easily search, find and copy-paste the files you want to recover.