Bug 396759 - [implementation] Editor saves over changed file
Summary: [implementation] Editor saves over changed file
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 4.3 M5   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 394884 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-12-17 09:53 EST by david collier CLA
Modified: 2013-01-29 09:22 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description david collier CLA 2012-12-17 09:53:50 EST
I find that if I open a file, make a change but do not save it to disk, then switch branches with egit, I get no prompt or reminder that my edit is incomplete, or that I may corrupt the equivalent file in the switched-to branch.

Should it be possible to switch branches with unsaved editing changes?
Comment 1 david collier CLA 2012-12-17 10:05:55 EST
see also my Bug 396757
Comment 2 Dani Megert CLA 2012-12-19 06:03:21 EST
*** Bug 394884 has been marked as a duplicate of this bug. ***
Comment 3 Dani Megert CLA 2012-12-19 06:12:57 EST
This is a major issue because the content from the branch is overwritten on save.

If a file is changed and saved, then EGit already shows it in the 'Checkout Conflicts' dialog. Hence, the simplest solution here is to save the dirty files before starting to switch the branch. This will automatically result in the 'Checkout Conflicts' dialog where one can decide what to do.
Comment 4 david collier CLA 2012-12-19 11:47:17 EST
That's one solution, though saving edits without the user actually agreeing to it is possibly a 'wrong thing in principle'.
I'd like to retain control over whether an experimental edit I've done gets written back to the source file I took it from. I may not mean it to happen.
 
You could alternatively simply pop-up "I'm not going to switch branches with dirty edits" and leave the user to pick the bones out of the situation for themselves. I'd prefer that.
Comment 5 Robin Stocker CLA 2012-12-19 13:01:01 EST
Why not show the same dialog we show when the user selects Team > Commit... and has unsaved files:

  'file' has been modified. Save changes?

                     [No] [Cancel] [Yes]

"Cancel" would abort the switch, "Yes" would save the file before switching. Only "No" would be a bit odd, it would have the same result as described in the description.
Comment 6 david collier CLA 2012-12-19 13:40:14 EST
could do - but for myself I wouldn't give the user the option of carrying the edited file to the other branch - it can't have any reasonable meaning that I can think of.
Comment 7 Dani Megert CLA 2012-12-20 08:27:22 EST
This seems to be a more general issue: I just noticed today that the same silently happens while pulling changes.

I would expect that the editor reports the conflict on save.
Comment 9 Dani Megert CLA 2013-01-29 09:22:43 EST
Verified with I20130128-2000 on Windows 7.