Tuesday, January 17, 2012

Removing the __history folders from a Delphi project

These days, the Delphi IDE maintains a history of all edits applied to your source files. It keeps track of these changes in a hidden subdirectory called __history. Which is nice and all(*), but as a developer I always have Show hidden files and folders turned on, which will make most of my VCS clients happily check the history folders into the real version control system... ouch!

Making a clean sweep

In my home setup, I use a simple clean.bat before each checking, including the following line:


for /d /r . %%d in (__history) do @if exist "%%d" rd /Q /S "%%d"


The recursive for + exist has a big advantage over the classic DIR /S ... it will not throw an obnoxious File Not Found if there happen to be no history folders at all.

Addendum: disabling the history in the IDE

Delphi 2010 and above make it really easy to disable the functionality. From the main menu, choose Tools, Options, Editor Options, then uncheck the Create backup files checkbox.



No more backup files or _history folders will be created, works like a charm!


(*) Not really, and I tend to turn it off... but I suspect Delphi updates turn it back on, and I share source with various people that prefer to leave it on, so I always end up with a lot of these folders in my source tree anyway.

No comments:

Post a Comment