require 'kvm/log' module KVM module Subversion # define class/static var @@SVN_ROOT="https://test.kuali.org/svn/" # no attr_* helpers for *class* variables :( def self.svn_root=(val); @@SVN_ROOT = val; end def self.svn_root; @@SVN_ROOT; end RICE_SERVER_DB_REPO_PATH="rice-cfg-dbs" RICE_CLIENT_DB_REPO_PATH="rice-cfg-dbs/rice-client-db" IMPEX_TOOL_REPO_PATH="kul-cfg-dbs" def self.checkout(base_dir, repo, path) dir = checkout_path(base_dir, repo, path) url = svn_url(repo, path) LOG.debug url command = "svn co #{url} #{dir}" LOG.debug command system(command) || raise("Error checking out #{repo} (#{path})") end def self.svn_url(repo, path) "#{@@SVN_ROOT}/#{repo}/#{path}" end def self.update(base_dir, repo, path) dir = checkout_path(base_dir, repo, path) system("svn update #{dir}") || raise("Error updating #{repo} (#{path})") end def self.checkout_path(base_dir, repo, path="trunk") File.expand_path(checkout_dirname(repo, path), base_dir) end def self.checkout_dirname(repo, path="trunk") "#{repo}__#{filepathify(path)}" end def self.parse_dirname(name) repo, path_mangled = name.split("__") [ repo, path_mangled.gsub('_', '/') ] end protected def self.filepathify(path) path.gsub('/', '_') end end end