Recent

Author Topic: Аutomatically save project files during compiling  (Read 11795 times)

Valentin

  • New Member
  • *
  • Posts: 18
Аutomatically save project files during compiling
« on: February 10, 2014, 12:56:48 am »
Lazarus saves project files during compiling, but it is not convenient in case you decide to exit the project and revert the files. This is what I miss from Delphi editor.

exdatis

  • Hero Member
  • *****
  • Posts: 668
    • exdatis
Re: Аutomatically save project files during compiling
« Reply #1 on: February 10, 2014, 07:09:46 am »
Use Mercurial:
http://easyhg.org/

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: Аutomatically save project files during compiling
« Reply #2 on: February 10, 2014, 12:29:18 pm »
Lazarus saves project files during compiling, but it is not convenient in case you decide to exit the project and revert the files. This is what I miss from Delphi editor.
Even Delphi introduced subversion in Delphi XE

http://www.drbob42.com/examines/examinD3.htm
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

hinst

  • Sr. Member
  • ****
  • Posts: 303
Re: Аutomatically save project files during compiling
« Reply #3 on: February 10, 2014, 01:00:41 pm »
Lazarus has backup feature (I believe it is enabled by default); it creates backup files in backup subdirectory; one can configure backup feature in options dialog window. For example you can chooose to keep 100 backup files so you will have lots of backup files for each file of your project; then you can find old version of file and revert it by copying it from backup folder to project dir

However using version control system is probably a better solution. I recommend mercurial because it is easy to use; IMO a lot easier than git or subversion
« Last Edit: February 10, 2014, 01:04:54 pm by hinst »
Too late to escape fate

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: Аutomatically save project files during compiling
« Reply #4 on: February 10, 2014, 01:07:40 pm »
Lazarus has backup feature (I believe it is enabled by default); it creates backup files in backup subdirectory; one can configure backup feature in options dialog window. For example you can chooose to keep 100 backup files so you will have lots of backup files for each file of your project; then you can find old version of file and revert it by copying it from backup folder to project dir

However using version control system is probably a better solution. I recommend mercurial because it is easy to use; IMO a lot easier than git or subversion

Yep version control is a better idea. I agree with you on Mercurial also.
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Аutomatically save project files during compiling
« Reply #5 on: February 10, 2014, 04:01:17 pm »
Lazarus saves project files during compiling, but it is not convenient in case you decide to exit the project and revert the files. This is what I miss from Delphi editor.

Pascal compiler is not part of the Lazarus IDE. Lazarus can call compiler only on the files on disk. That is why all files must be saved before compilation.

Valentin

  • New Member
  • *
  • Posts: 18
Re: Аutomatically save project files during compiling
« Reply #6 on: February 12, 2014, 12:52:22 am »
Pascal compiler is not part of the Lazarus IDE. Lazarus can call compiler only on the files on disk. That is why all files must be saved before compilation.

It's possible to use a temp files created by lazarus just before comiling, so the original files remain unsaved...

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Аutomatically save project files during compiling
« Reply #7 on: February 12, 2014, 03:53:27 am »
Mark "Undo After Save" on Tools > Options > Editor > General and simply undo the changes after compiling.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Аutomatically save project files during compiling
« Reply #8 on: February 12, 2014, 04:51:11 am »
Yes it would be possible to save to a temp directory.

But nobody has yet implemented it.....

A patch would certainly be welcome. But it is not trivial, since files may depend on other files in that directory, so those also need to be saved. All search path must be updated. "Uses Unit1 in FileName1" must be taken care off. Maybe the new dotted unit name also require files in the correct places....

Just copy the backups back.

But best is always a local repository (git, svn, anything). And commit often, really often.
If something gives trouble 2 month (even years) after you changed it (maybe conflicts with another change you try to make), then you can still have a look at what exactly you changed back then, maybe even roll back the one revision only.
And with good log messages you also know why you did it.


georgebou

  • New Member
  • *
  • Posts: 45
Re: Аutomatically save project files during compiling
« Reply #9 on: February 19, 2014, 01:40:38 am »
A simple solution that could be implemented is the following:
Let's suppose we have to compile unit1.pas 

a. Copy the original file unit1.pas to a file named unit1.old
b. Now change everything you like and experiment on code.
c. when you compile the file, the editor saves the file and fpc compiles unit1.pas as it does and now.

Now we have 2 options:
a. if the user decides not to save the changes, unit1.pas should be deleted and file unit1.old should be renamed to unit1.pas
d. if the user decides to save changes, unit1.pas remains as it is and the file unit1.old is deleted.

This method doesn't affect dependencies and other things and it's simple.

I hope they implement it.

BjPascal

  • New Member
  • *
  • Posts: 15
Re: Аutomatically save project files during compiling
« Reply #10 on: July 20, 2018, 11:57:41 pm »
Now 4 more years have passed, and I wonder: Has anything improved in this matter? At least I haven't found any option pointing in this direction.


lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Аutomatically save project files during compiling
« Reply #11 on: July 21, 2018, 12:22:11 am »
I have just the opposite thing
https://github.com/lainz/LazAutoSave

That saves everything automatically each x seconds (if there is something to save).

I agree than you should use versioning.

But check that code, maybe you can tweak it to do the opposite: prevent saving. I mean make a plugin for the IDE..

I didn't make it fully, I got help from GetMem and JuhaManninen.
« Last Edit: July 21, 2018, 12:24:17 am by lainz »

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Аutomatically save project files during compiling
« Reply #12 on: July 21, 2018, 12:23:07 am »
@ Has anything improved in this matter?

Nothing, becuase there was no need. There's undo for recent changes and version control systems or older changes.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

 

TinyPortal © 2005-2018