Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364097 - Revert Failed Error
Summary: Revert Failed Error
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: 1.1   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 1.2   Edit
Assignee: Kevin Sawicki CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-17 20:08 EST by Miles Parker CLA
Modified: 2011-11-29 18:46 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Miles Parker CLA 2011-11-17 20:08:12 EST
I'm getting a rather mysterious error..  I had just committed a change and wanted to revert to the previous commit. Looking at the Reverting Changes section,  "Reverting changes introduced by a specific commit" seemed to fit the bill. So I:

1. Right clicked on a project and selected "History.."
2. From the list selected the top-most Master | HEAD entry.
3. Right-clicked and selected Revert commit.

I get the message:

"The revert failed" [sic] It isn't logged to the error log, only shown.

Perhaps I'm doing this wrong and need to pick the prior commit, i.e. the one I'm trying to revert *to* but I'm afraid to experiment too much. :)
Comment 1 Kevin Sawicki CLA 2011-11-21 19:39:49 EST
Can you elaborate a bit about what was in the commit you wanted to revert?

Was it all added files, edited files, deleted files?
Comment 2 Miles Parker CLA 2011-11-21 19:55:47 EST
All of the above. It was a pretty significant refactoring, so it involved renamed, moved, and deleted files as well as quite a few edits. I'm sorry, that probably doesn't help much.
Comment 3 Matthias Sohn CLA 2011-11-25 18:34:16 EST
This is hard to reproduce without more detailed information on what
you did.

What do you mean by revert to the previous commit ? Do you want to 
remove the last commit from the history and rewind the working tree 
to that state ? Then you should rather do a hard reset on the previous 
commit. 

Revert creates another commit on top of current HEAD which applies 
the opposite diff of the commit you clicked "revert" on. So it's not 
removing the last commit but adding another one on top which reverts 
the effect of the previous commit (diff is reverse of the previous commit).
Comment 4 Miles Parker CLA 2011-11-25 19:04:42 EST
(In reply to comment #3)
> This is hard to reproduce without more detailed information on what
> you did.
> 
> What do you mean by revert to the previous commit ? Do you want to 
> remove the last commit from the history and rewind the working tree 
> to that state ? Then you should rather do a hard reset on the previous 
> commit. 

Yes, that's what I ended up doing. But the docs seemed to indicate that this was a better way to go.

http://wiki.eclipse.org/EGit/User_Guide#Reverting_changes_introduced_by_a_specific_commit

"Changes which are introduced by a given commit can be reverted by an automatically created new commit on top of the currently checked out commit. The commit which is to be reverted does not have to be checked out for that."

My thinking was that this way I could avoid having to deal with merging all of the changes back in to my upstream repos. As it turns out, I didn't have to, but I *did* lose the record of my changes that I had rolled back, which isn't ideal.

> Revert creates another commit on top of current HEAD which applies 
> the opposite diff of the commit you clicked "revert" on. So it's not 
> removing the last commit but adding another one on top which reverts 
> the effect of the previous commit (diff is reverse of the previous commit).

Right, that's exactly what I wanted to do. IOTW, I wanted to keep the linear record of the change that I had made. Ideally I guess I would have created a branch for that, but I wasn't thinking ahead.

Anyway, the basic issue is the error, not whether it was the right thing to do or not. :) And the part of that that is really the concern is how the error was presented. There seems to be a hole in the exception handling somewhere.

But sorry, beyond the basic explanation of the steps I took, I can't think of anything to suggest in terms of reproducing. I'm assuming that you tried [or a unit test exists for] doing a number of changes and then triggering that option.
Comment 5 Miles Parker CLA 2011-11-28 22:05:22 EST
One other thought I had on this.. I'm doing a lot of code generation as part of this. When that happens, it's always possible that the Eclipse file system wasn't synched properly prior to the commit. I usually try to do that manually before a commit just to be sure...but a possibility that there might have been some kind of inconsistent state there.
Comment 6 Kevin Sawicki CLA 2011-11-29 12:13:46 EST
JGit now provides the reason behind a revert failure so we can now give a better message in EGit when this happens.

I am working on a new dialog that shows why the revert failed such as dirty index, dirty working tree, or failure to delete files.
Comment 7 Miles Parker CLA 2011-11-29 13:44:48 EST
(In reply to comment #6)
> JGit now provides the reason behind a revert failure so we can now give a
> better message in EGit when this happens.
> 
> I am working on a new dialog that shows why the revert failed such as dirty
> index, dirty working tree, or failure to delete files.

OK, that works for me. As I say, the real issue for me was just not having anything to go on at all. You could just make this one a dup of that or however you want to resolve it.
Comment 8 Kevin Sawicki CLA 2011-11-29 16:46:00 EST
Pushed new revert error dialog: http://egit.eclipse.org/r/#change,4695

Screenshot here: http://img.skitch.com/20111129-gsn29wxtpmreu1wjig3astetew.png
Comment 9 Miles Parker CLA 2011-11-29 16:59:18 EST
(In reply to comment #8)

+1
Comment 10 Kevin Sawicki CLA 2011-11-29 18:46:01 EST
Merged into master as commit ed315802df8ad278ad257a675c9cb86f11e02213