Home | Reviews | GUIpedia | Forum | Fun500


pharoahSimple version control utility
Have you ever made radical changes to your code, only to find it's stopped working and you have no backup of the original? That's what version control software is for. There are big fancy online solutions like CVS and SubVersion that allow for collaborative coding, but rather than spend the time learning and installing either one I figured it would be easier and more practical just to whip something up in FB. The program I've come up with is called Reversion, and it is designed to keep a historical record of source code (or really any text file) in one long .rev file. When you check in, it appends the latest version of your code to the .rev along with a timestamp and optional description. When you want to revert, you simply select the checkout option and choose the version you want to revert to by a date and description listing. Another nice thing is that this is a text file and it's easy to read, so if you don't have the reversion software handy you can easily copy out the code you want. Here's my program, feedback would be appreciated: [code] 'Reversion Source Management System type revType timestamp as string description as string start as integer lines as integer end type declare sub checkin(path as string) declare sub checkout(path as string) dim path as string dim char as string Print "Welcome to Reversion" input "Source path: ",path do cls print "Source: "+path print print "Options:" print ,"i - CheckIn" print ,"o - CheckOut" print ,"q - Quit" char = "" while char "i" and char "o" and char "q" char = input(1) wend select case char case "i" CheckIn(path) case "o" CheckOut(path) case "q" end case chr(27) end end select loop sub checkin(path as string) dim description as string line input "Description: ", description var revname = left(path, instr(path, ".")-1)+".rev" var crlf = chr(13)+chr(10) open path for input as #1 open revname for binary as #2 seek #2, lof(2)+1 if lof(2) = 0 then put #2,, "This is a reversion source repository."+crlf end if put #2,, string(80, "=")+crlf put #2,, "Date: "+date+" "+time+crlf put #2,, "Description: "+description+crlf put #2,, "Lines: " var headerseek = seek(2) put #2,, " "+crlf put #2,, string(80, "-")+crlf dim lines as integer dim temp as string while not eof(1) line input #1, temp put #2,, temp+crlf lines += 1 wend seek #2, headerseek put #2,, str(lines) close 1 close 2 end sub sub checkout(path as string) dim revs() as revtype var revname = left(path, instr(path, ".")-1)+".rev" open revname for input as #1 dim temp as string line input #1, temp 'Grab intro text dim k as integer var i = 1 while not eof(1) redim preserve revs(1 to i) line input #1, temp 'Grab first divider line input #1, temp 'Grab timestamp revs(i).timestamp = mid(temp, len("Date: ")+1) line input #1, temp 'Grab description revs(i).description = mid(temp, len("Description: ")+1) line input #1, temp 'Grab lines revs(i).lines = valint(mid(temp, len("Lines: ")+1)) line input #1, temp 'Grab last divider revs(i).start = seek(1) for k = 1 to revs(i).lines line input #1, temp next k i += 1 wend for i = 1 to ubound(revs) print "#"+str(i), revs(i).timestamp, revs(i).description next input i open path for output as #2 seek 1, revs(i).start for k = 1 to revs(i).lines line input #1, temp print #2, temp next close 1 close 2 end sub [/code]
2009-04-036:26 PM

agumaRe:Simple version control utility
Neat! Haven't tried it yet, but good idea!
2009-04-037:57 PM

ksrRe:Simple version control utility
This could be quite handy. Though whenever I make a big change to a file I create a copy of it just in case things go completey wrong.
2009-04-038:21 PM

Other


2021 Brandon Cornell