Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (30 sloc) 879 Bytes
#!/usr/bin/env ruby
# -*- encoding: UTF-8 -*-
def get_diff_files(svn_path, rev1, rev2)
diff = `svn diff -r #{rev1}:#{rev2} #{svn_path} | grep '^Index:'`
end
def export_files(file_list, rev2, destination, svn_path)
# svn export --force -r rev2 file_path
file_list.each do |f|
dir = File.dirname(f.sub(/^Index:\s*/, '').gsub(/\s/,'\\ '))
file = File.basename(f).chomp
origin = [dir,file].join('/')
out = destination + origin.sub(svn_path,'')
mkdir = "mkdir -pv #{File.dirname(out)}"
cmd = "svn export --force -r #{rev2} #{origin}"
mv = "mv #{file} #{out}"
#puts mkdir
system(mkdir)
#puts cmd
system(cmd)
#puts mv
system(mv)
puts out
end
end
if __FILE__ == $0
svn_path, rev1, rev2, destination = ARGV
diffs = get_diff_files svn_path, rev1, rev2
puts diff
export_files diffs, rev2, destination, svn_path
end