0

The title says it all. I made some changes & closed/re-opened Delphi, so I Can't use Ctrl-Z to undo my changes.

How do I compare the current file with previous versions?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551
  • 4
    Use your revision control system – David Heffernan May 11 '15 at 18:09
  • 2
    For code only, if you don't have a version control system installed, you can view recent history by using the *History* tab at the bottom of the code editor window, and then click the *Differences* tab. How far back you can go depends on how you've configured it; the default is 10 revisions. – Ken White May 11 '15 at 18:25
  • @KenWhite please post that as an answer. I was aware of it from previous versions, but had forgotten how to activate it. "at the bottom of the code editor window" were the magic words. Dumb, I know, and probably a warning that I am too tired to code further (hence the need to undo some changes) – Mawg says reinstate Monica May 11 '15 at 18:48
  • Done. Added info about how to change the default limit as well. – Ken White May 11 '15 at 18:58
  • Ctrl-Z works very well for several saved editions of the file, unless you specifically prevent it. Look in Tools - Options - Editor Options. First checkbox in the right column is labelled 'Undo after save'. By default it is on. – Tom Brunberg May 12 '15 at 08:51
  • But I closed/re-opened Delphi – Mawg says reinstate Monica May 12 '15 at 09:54
  • Oooops! Sorry, my bad. – Tom Brunberg May 12 '15 at 13:35

3 Answers3

4

For code only, if you don't have a version control system installed, you can view recent changes by using the History tab at the bottom of the code editor window, and then click the Differences tab. How far back you can go depends on how you've configured it; the default is 10 revisions. You can change the default in Tools->Options->Editor Options->File backup limit.

Ken White
  • 123,280
  • 14
  • 225
  • 444
3

In the absence of any other revision control system there is a History tab in the code editor window - from there you can view a side-by-side diff with previous saved versions by using the Differences tab.

If you installed BeyondCompare with XE8 then you can also access a revision history of your files by selecting (with the file of interest open in the IDE)

Edit -> Compare -> History Compare...

This will present you with a list of saved revisions. Select one and click the Show Diff... button to present a side-by-side comparison.

Going forward, I would seriously consider using dedicated revision control. Commit often and this type of situation should never be a problem for you.

J...
  • 30,968
  • 6
  • 66
  • 143
  • Err, BeyondCompare is a revision control system ? I thought the history is being saved as those .~n~ files in the `__history` folder and that comparison takes it from there if you don't explicitly setup a version control system. But maybe I'm wrong... – TLama May 11 '15 at 18:25
  • @TLama ...hence my use of the term "basic". It's not real version control, but it provides *some* of the most basic life-saving features (ie: at least a record of the file's change history). Perhaps even that terminology suggests too much about its capabilities. I will change the wording. – J... May 11 '15 at 18:27
  • Saving file history as such is done by the IDE (you can find settings for the file backup limit in editor options) for at least a decade. BeyondCompare is IMHO just a file comparer that can compare files either from that backup, or from the assigned version control system, but it's not necessary to have it, I think. At least not for that backup feature. And some basic file comparer seems to be built-in in the IDE if I'm not misaken (or at least I don't know that I would install BeyondCompare into my Delphi 2009). – TLama May 11 '15 at 18:34
  • @TLama Fair enough. I've never actually explored this in any detail, I use SVN so I've never had a need to dig up diffs this way. Looking at it now, it seems most of the stuff in that History tab comes from my SVN repository anyway. I'll update the answer. – J... May 11 '15 at 18:37
  • I'm using SVN too, but also the history files in between commits, or when something bad happens before commit. I've learned to save quite frequently (UPS failure crashing the system gives you a lesson :), so frequent commits to SVN would be just slowing me down. – TLama May 11 '15 at 18:50
-2

if you have a version control system then use this.

else: if you use Win7 then right-click the file, choose properties and see "older versions". You have to have enabled this Win feature beforehand...

else: your previous versions are lost

casiosmu
  • 797
  • 1
  • 8
  • 22
  • 1
    Previous versions kept by windows are only sampled when a restore point is created. This is almost invariably not going to be useful for detecting a recent change. – J... May 11 '15 at 18:14
  • @J... No, it's more frequent than that, but still not likely to be useful. – David Heffernan May 11 '15 at 18:25
  • 1
    @DavidHeffernan The "Previous Versions" window contains the text : `Previous versions come from restore points or from Windows Backup.` Can the behaviour be modifed beyond that? – J... May 11 '15 at 18:29
  • @J... The amount of older versions of a specific file that is maintained by windows heavily depend on the restore point settings. You see on Windows (beginning from Windows 2000) you are able to allocate limited amount of disk space to be used for storing of older versions of files that has been changed. When all that available space is used windows starts erasing the oldest versions. But there is one exception. if the older version of that specific file was stored as part of restore point windows will go and rather delete older revision of some other file which was stored ... – SilverWarior May 11 '15 at 20:37
  • ... after that file which is not part of a restore point was simply changed. This behavior allows the restore points to be valid for longer time. So if you are frequently occurring cases when the previous versions of your files are not stored or only a few previous versions are stored try increasing the amount of disk space that can be used for restore point. Also it is sometimes good to go and manually delete some of the older restore points to free up some disk space. Unfortunately I forgot how you do that. – SilverWarior May 11 '15 at 20:40