#!/usr/bin/ruby -w

oldvers = ARGV[0]
oldversurl = ARGV[1]
newvers = ARGV[2]
newversurl = ""
newversurl = ARGV[3] if ARGV.size > 3

#b = `svn log #{oldversurl} | head -2 | tail -1 | ruby -nale 'puts $F[1].chop'
newrev = `svn log | head -2 | tail -1`.split[1].chop
oldrev = `svn log #{oldversurl} | head -2 | tail -1`.split[1].chop
puts "New version = #{newvers} #{newrev}"
puts "Old version = #{oldvers} #{oldrev}"

fout = File.new( "docs/changelog.txt", "a" )
fout << "<log version='#{newvers}'>"
fout << `svn log --incremental --xml -r #{newrev}:#{oldrev}`
fout << "</log>"
fout.close

# then..
fout = File.new( "docs/changelog.xml", "w" )
fout << "<logs>"
fout << File.new("docs/changelog.txt").readlines.join("\n")
fout << "</logs>"
fout.close

`xsltproc -o docs/changelog.html docs/transform/log.xsl docs/changelog.xml`
