Subclipse: Change file state from Incoming Change to Outgoing Change - eclipse

I have a project in eclipse versioned to a SVN repository using subclipse.
In that project I took an older revision of a file and want to commit it as a new revision but when I right click it and go to Team -> Synchronize with Repository Subclipse shows me the file as if it has incoming changes (since the file is bound to an old revision and there's a new one on the repository).
How can I tell subclipse that I want to Override and commit the current version of the file?

You cannot do what you want using the approach you took. SVN is bring "too smart" here.
You cannot commit a file unless the local version is at the HEAD revision. You apparently pulled in an old revision of the file in a way that SVN knows this. So SVN is not going to allow you to commit that file without first updating it to HEAD.
What you want to do is get the "content" of the file at the old revision, rather than getting the old revision itself. Here is how to do this:
1) Go ahead and update the file back to HEAD revision. This will get rid of the current contents but that is fine.
2) Right click on the file and choose Team > Show History
3) In the History, find the revision you want and select it. Right-click and choose the "Get Contents" option. This will pull in the content of the file at that revision, but leave the working copy metadata at HEAD revision.
The file should now show as a local modification. Diff should work etc. and you can now commit it.

Related

How to update SVN source using subclipse

I am using subclipse plugin in Eclipse to use SVN repo. for commit the source changes i use [Right click -> Team -> Commit]
I need to pull the latest changes from SVN repo. i am seeing options for updating the source
Right click -> Team -> Update to Head &
Right click -> Team -> Update to Version
Which one i have to use to update the latest changes in my local repo and what is the difference between them. Please suggest.
The difference is following:
Update to HEAD will do svn update.
In other words it will update your working copy to the last revision from the repository.
Synchronize with Repository is something similar to svn status -u, but even more.
It will open a Synchronize tab (or perspective) that displays overview of your local (outgoing) modifications versus repository (incoming) modifications.
In this tab or perspective, you can review and synchronize (commit / update) individual files, see differences between your working copy files and incoming files from repository, browse commits history, resolve conflicts.
Update to Revision:
The standard Update command has no options and just updates your working copy to the HEAD revision of the repository, which is the most common use case. If you want more control over the update process, you should use TortoiseSVN → Update to Revision... instead. This allows you to update your working copy to a specific revision, not only to the most recent one. Suppose your working copy is at revision 100, but you want it to reflect the state which it had in revision 50 - then simply update to revision 50
Update to Revision can occasionally be useful to see what your project looked like at some earlier point in its history. But in general, updating individual files to an earlier revision is not a good idea as it leaves your working copy in an inconsistent state. If the file you are updating has changed name, you may even find that the file just disappears from your working copy because no file of that name existed in the earlier revision. You should also note that the item will show a normal green overlay, so it is indistinguishable from files which are up-to-date.
In general, I highly recommend you to check out the SVN Handbook. At least first two chapters.

Github and Eclipse: not all files are commited

I´m using Github in Eclipse, and commiting my changes to it. I have added some files to my project, and I have clicked on Team->"Add to index" in each of them, for them to be commited when I make a commit of the whole project. However, these files are not added to be commited, and when I click in "Commit", they arent´shown in the list of modified files. How can I force them to be commited?
Thanks.
It sounds like you may be confusing the usage of Git wit SVN. In SVN when you add a file to be tracked, updates to the file will always be committed automatically.
In Git, when you add a file to the index, only the current version of that file is recorded. If you subsequently update the file and commit, the new updates won't be included. The solution is to do an "Add to index" on the root of your project right before you commit: the equivalent of git add . on the commandline. Make sure your .gitignore is set up correctly so you don't commit things you don't intend to.
An equivalent action is to do a git commit -a, which automatically adds all files previously in the index and updates any deleted files as well. I believe the equivalent setting in Eclipse (for eGit) would be to Include selected untracked files as in the commit settings below.

I commited an svn file delete and now I want it back

I deleted a bunch of files from my env and committed the changes.
Of course I now want one of them back.
What is the best way to bring the ONE file back out of the revision?
I have brought the file up from View History on the package (it is a java file), but don't see a way to bring it back short of copy and paste.
Eclipse 3.7.0, subclipse 1.6
UPDATE
It looks like Antonio Pérez and qor72 solutions both accomplish the goal. Antonio's can be done in eclipse but the number of reverts can be large. Also merge requests that one commit open changes.
I like qor72's solution. To access copy in this scenario:
look at the history and find the deleted file.
right click on file name and choose copy.
select the original directory.
OK.
What I have done in the past is ressurrect the file per the SVN documentation, for example:
$ svn copy ^/calc/trunk/real.c#807 ./real.c
Then readd/commit and off you go.
Probably the subclipse client would allow a simple way of doing it. But if you'd like to give a try to the command line client.
$ cd <working_copy_path>
$ svn merge repo_url[#M] repo_url[#M-1]
M is the revision where you committed the deleted files. And you should get back all the files you deleted as added files in your working copy. Then
$ svn commit <your_file_to_be_recovered>
$ svn revert (to remove the rest of added file that you don't need back)
Further info on the svn merge command.
you can follow these steps to get it back
1. Identify the folder in the project which contained the deleted files.
2. Right click the folder, select Team -> Merge
Within Merge Pop up Window
3. On the URL tab, Browse and select the "repository resource to merge with" i.e the same folder in the repository.
4. Select Revisions radio button,
5. Click Browse button to select revisions.
6. Select the revisions which you want to be restored ( select the revision wherein you deleted the files / folders )
7. Enable Reversed merge.
8. Click Preview and check that it shows an entry for the file / folder which you plan to restore.
9. Click OK
10. Eclipse now switches to SVN Merge and with the Synchronize view.
11. In the Synchronize view, right click the files you want and select Accept
12. 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.
13. Right click the file -> Team -> commit to check in the file again to the repository.

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.

Rolling back bad changes with svn in Eclipse

Let's say I have committed some bad changes to Subversion repository. Then I commit good changes, that I want to keep.
What would be easiest way to roll back those bad changes in Eclipse, and keep the good changes? Assuming that files relating to bad changes are not same as those relating to the good changes. How things change if good changes were made to same files as bad changes?
I am mostly looking a way to do this via Eclipse plugins (Subclipse or Subversive) but commandline commands are also interesting.
In Eclipse Ganymede (Subclipse)
Select project/file that contains bad change, and from pop-up menu choose:
Team -> Show History
Revisions related to that project/file will be shown in History tab.
Find revision where "bad changes" were committed and from pop-up menu choose:
Revert Changes from Revision X
This will merge changes in file(s) modified within bad revision, with revision prior to bad revision.
There are two scenarios from here:
If you committed no changes for that file (bad revision is last revision for that file), it will simply remove changes made in bad revision. Those changes are merged to your working copy so you have to commit them.
If you committed some changes for that file (bad revision is not last revision for that file), you will have to manually resolve conflict. Let say that you have file readme.txt with, and bad revision number is 33. Also, you've made another commit for that file in revision 34. After you choose Revert Changes from Revision 33 you will have following in your working copy:
readme.txt.merge-left.r33 - bad revision
readme.txt.merge-right.r32 - before bad revision
readme.txt.working - working copy version (same as in r34 if you don't have any uncommitted changes)
Original readme.txt will be marked conflicted, and will contain merged version (where changes from bad revision are removed) with some markers (<<<<<<< .working etc). If you just want to remove changes from bad revision and keep changes made after that, then all you have to do is remove markers. Otherwise, you can copy contents from one of 3 files mentioned above to original file. Whatever you choose, when you are done, mark conflict resolved by
Team - Mark Resolved
Temporary files will be removed and your file will be marked changed. As in 1, you have to commit changes.
Note that this does not remove revision from revision history in svn repository. You simply made new revision where changes from bad revision are removed.
You have two choices to do this.
The Quick and Dirty is selecting your files (using ctrl) in Project Explorer view, right-click them, choose Replace with... and then you choose the best option for you, from Latest from Repository, or some Branch version. After getting those files you modify them (with a space, or fix something, your call and commit them to create a newer revision.
A more clean way is choosing Merge at team menu and navigate through the wizard that will help you to recovery the old version in the actual revision.
Both commands have their command-line equivalents: svn revert and svn merge.
If you want to do 1 file at a time you can go to the History view for the file assuming you have an Eclipse SVN plugin installed. "Team->Show History"
In the History view, find the last good version of that file, right click and choose "Get Contents". This will replace your current version with that version's contents. Then you can commit the changes when you've fixed it all up.
In Eclipse using Subversive:
Right click your project > Team > Merge
In the merge window, select the revisions you want to revert as normally but also enable checkbox "Reversed merge".
Merge as normally.
I have written a couple of blog posts on this subject. One that is Subclipse centric: http://markphip.blogspot.com/2007/01/how-to-undo-commit-in-subversion.html and one that is command-line centric: http://blogs.collab.net/subversion/2007/07/second-chances/
The svnbook has a section on how Subversion allows you to revert the changes from a particular revision without affecting the changes that occured in subsequent revisions:
http://svnbook.red-bean.com/en/1.4/svn.branchmerge.commonuses.html#svn.branchmerge.commonuses.undo
I don't use Eclipse much, but in TortoiseSVN you can do this from the from the log dialogue; simply right-click on the revision you want to revert and select "Revert changes from this revision".
In the case that the files for which you want to revert "bad changes" had "good changes" in subsequent revisions, then the process is the same. The changes from the "bad" revision will be reverted leaving the changes from "good" revisions untouched, however you might get conflicts.
I have same problem but CleanUp eclipse option doesn't work for me.
1) install TortoiseSVN
2) Go to windows explorer and right click on your project directory
3 Choice CleanUp option (by checking break lock option)
It's works.
Hope this helps someone.