File versioning

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
miskox
Enthusiast
Enthusiast
Posts: 107
Joined: Sun Aug 27, 2017 7:37 pm
Location: Slovenia

File versioning

Post by miskox »

Hello!

I have a suggestion I would like you to think about it.

For example I have a source file test_file.pb.

I then change something and I press CTRL-S to save the file. And then I change something else and again I press CTRL-S.

It would be nice to have something like file versioning*.

After I would press the CTRL-S combination for the first time my original test_file.pb would be renamed to test_file.pb.1** and the new version would be saved as test_file.pb. After my second CTRL-S this current test_file.pb. would be saved as test_file.pb.2 and the new file would be named test_file.pb.

In this way I would have some backup of my work. I would just copy/rename the version that was good.

Thoughts?

Thanks.
Saso

* I worked on OpenVMS (VAX, ALPHA) for more than 20 years so I know this is very useful.
I know that PureBasic supports 'Session history'. Maybe this could be useful, too for some people. (this could be turned on/off in the settings)

** PB would scan the file system and check for the highest version number so it does not replace an existing file.
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: File versioning

Post by skywalk »

Try out the built-in Session History which tracks changes up to 1 month.
If that is not sufficient, then write a Tool code that triggers your flavor of Version Control.
I prefer Fossil, which stores all changes in a single SQLite database and gives you a web page gui for timelines & diffs, email, forum, wiki, etc.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Bitblazer
Enthusiast
Enthusiast
Posts: 761
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: File versioning

Post by Bitblazer »

Code: Select all

on create/save file($name)
del $name.9
ren $name.8 $name.9
ren $name.7 $name.8
ren $name.6 $name.7
ren $name.5 $name.6
ren $name.4 $name.5
ren $name.3 $name.4
ren $name.2 $name.3
ren $name.1 $name.2
ren $name $name.1
save $name
iirc thats how the vms fs does it. Indeed pretty useful and very old by now (read: likely any IP right that existed, is void now). One of the "old" forgotten methods that were pretty useful - and make a lot sense for terabyte harddisks and sources (not so much for videofiles or most databases)
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: File versioning

Post by Dude »

skywalk wrote:Try out the built-in Session History which tracks changes up to 1 month.
It defaults to one month, but you can also disable the limit or change the duration in the Prefs. My history is set to 365 days.
User avatar
Derren
Enthusiast
Enthusiast
Posts: 316
Joined: Sat Jul 23, 2011 1:13 am
Location: Germany

Re: File versioning

Post by Derren »

Can even be set to "Keep all history".
Good to know :)
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 283
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: File versioning

Post by oreopa »

Save as new version (filename + "_num" + ext) should be mandatory in ALL software by now. :)

I would also like to semi-hijack and reiterate a FR I had, that it would be great if the tokens %BUILDCOUNT and %COMPILECOUNT could be used in a filename, and they autoupdated to reflect each version saved.

I already wrote my own tools for simple source control because I dont actually find the built in session history that useful. (EDIT: however it did save my ass once, so... ;) )
skywalk wrote:I prefer Fossil, which stores all changes in a single SQLite database and gives you a web page gui for timelines & diffs, email, forum, wiki, etc.
Seems like it may be useful to me soon, thx.
Proud supporter of PB! * Musician * C64/6502 Freak
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: File versioning

Post by Tenaja »

Not sure how well this will coordinate with Session History, but this is what I do for my About version display:

Code: Select all

#UpdaterThisVersion = "Beta"
Version$ = #UpdaterThisVersion
Version$ + FormatDate(".%yy.%mm.%dd.", #PB_Compiler_Date) + Str(#PB_Editor_BuildCount)
The PB constants are taken at compile time, so you can tell how many times you have compiled between saved exe's.
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: File versioning

Post by Michael Vogel »

What about writing an own purebasic program which will be added as a tool into the IDE?

By assigning the shortcut Ctrl+S it would be triggered to save the source code as wanted, make backups and so on - it could even modify the source code by adding a comment with the actual version number etc.
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: File versioning

Post by skywalk »

Well, version control is an established and optimized function that does not make sense to reattempt. It would be more efficient to develop pb tool code that would trigger check in/check out of git or fossil repositories. :wink:
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
miskox
Enthusiast
Enthusiast
Posts: 107
Joined: Sun Aug 27, 2017 7:37 pm
Location: Slovenia

Re: File versioning

Post by miskox »

Thank you all. First sorry for a late reply - I've been out of the country for a few days.

@Bitblazer: great. But the newest version should have highest version.

@tenaja: very good tips. Thanks.

Saso
Post Reply