+1

Auto file backup on Discard

Sync 9 months ago • updated by Thomas Singer 9 months ago 6

In SnapshotCM, this program will always make a .bak copy of the file (saved in the same folder) on every "Discard" message.  If there is already a .bak file, it just increments to .bak1 on the next "Discard".


This feature is really handy to cater the case of accidental Discards (e.g. laggy computer, clicked on wrong button).


Having a bunch of .bak file in the workspace was a bit annoying.  So, if SmartGit wants to implement a similar safety feature, I suggest:

  • Saving it somewhere in %localappdata%.  It can probably just follow the hierarchy of the workspace.
  • User then invokes a "See backups" button, which opens up a window (like the Log Window).
  • By default, save only up to 5 backups per file (or something like that, to prevent extreme accumulation).  The idea is to mainly to cater accidental Discards, or recent Discards.
  • It can be turned off by default, and is an opt-in option so user knows where the backups are saved (or perhaps allow the user to pick a backup space).

I'm surprise you're suggesting this... Did you try to commit / amend very regularly instead ?

Can that prevent accidental Discard?


Consider this scenario:

  • 4 files modified
  • I want to discard justt 1 file, and have selected that one file
  • For some reason, the [Files] tab lost focus, and [Repositories] is now in focus
  • Clicked "Discard".  I assumed only 1 file is selected (if [Files] was in focus), but now all files are selected.
  • I didn't concentrate, and hit Discard.

Accidently Discard is prevented by a confirmation dialog.

Side question:  why does SmartGit still select all files during a discard (if [Files] went out of focus), when only 1 file is selected is [Files]?

Maybe because you've invoked the Discard with the focus in the Repositories view and not in the Files view? If the focus is in the Repositories view the Files view selection does not matter for any command.

Oh ok. Maybe simply use right click / discard on the file then ?