Methods
A
B
E
G
S
T
U
W
Class Public methods
get_revisions(path, srcdir = nil)
# File tool/vcs.rb, line 168
def self.get_revisions(path, srcdir = nil)
  if srcdir and local_path?(path)
    path = File.join(srcdir, path)
  end
  if srcdir
    info_xml = IO.pread(%W"svn info --xml #{srcdir}")
    info_xml = nil unless info_xml[/<url>(.*)<\/url>/, 1] == path.to_s
  end
  info_xml ||= IO.pread(%W"svn info --xml #{path}")
  _, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
  modified = info_xml[/<date>([^<>]*)/, 1]
  branch = info_xml[%r'<relative-url>\^/(?:branches/|tags/)?([^<>]+)', 1]
  [last, changed, modified, branch]
end
search_root(path)
# File tool/vcs.rb, line 183
def self.search_root(path)
  return unless local_path?(path)
  parent = File.realpath(path)
  begin
    parent = File.dirname(wkdir = parent)
    return wkdir if File.directory?(wkdir + "/.svn")
  end until parent == wkdir
end
Instance Public methods
after_export(dir)
# File tool/vcs.rb, line 277
def after_export(dir)
  FileUtils.rm_rf(dir+"/.svn")
end
branch(name)
# File tool/vcs.rb, line 213
def branch(name)
  url + "branches/#{name}"
end
branch_list(pat)
# File tool/vcs.rb, line 225
def branch_list(pat)
  IO.popen(%W"svn ls #{branch('')}") do |f|
    f.each do |line|
      line.chomp!
      line.chomp!('/')
      yield(line) if File.fnmatch?(pat, line)
    end
  end
end
export(revision, url, dir, keep_temp = false)
# File tool/vcs.rb, line 247
def export(revision, url, dir, keep_temp = false)
  if @srcdir and (rootdir = wcroot)
    srcdir = File.realpath(@srcdir)
    rootdir << "/"
    if srcdir.start_with?(rootdir)
      subdir = srcdir[rootdir.size..-1]
      subdir = nil if subdir.empty?
      FileUtils.mkdir_p(svndir = dir+"/.svn")
      FileUtils.ln_s(Dir.glob(rootdir+"/.svn/*"), svndir)
      system("svn", "-q", "revert", "-R", subdir || ".", :chdir => dir) or return false
      FileUtils.rm_rf(svndir) unless keep_temp
      if subdir
        tmpdir = Dir.mktmpdir("tmp-co.", "#{dir}/#{subdir}")
        File.rename(tmpdir, tmpdir = "#{dir}/#{File.basename(tmpdir)}")
        FileUtils.mv(Dir.glob("#{dir}/#{subdir}/{.[^.]*,..?*,*}"), tmpdir)
        begin
          Dir.rmdir("#{dir}/#{subdir}")
        end until (subdir = File.dirname(subdir)) == '.'
        FileUtils.mv(Dir.glob("#{tmpdir}/#{subdir}/{.[^.]*,..?*,*}"), dir)
        Dir.rmdir(tmpdir)
      end
      return true
    end
  end
  IO.popen(%W"svn export -r #{revision} #{url} #{dir}") do |pipe|
    pipe.each {|line| /^A/ =~ line or yield line}
  end
  $?.success?
end
get_info()
# File tool/vcs.rb, line 192
def get_info
  @info ||= IO.pread(%W"svn info --xml #{@srcdir}")
end
grep(pat, tag, *files, &block)
# File tool/vcs.rb, line 235
def grep(pat, tag, *files, &block)
  cmd = %W"svn cat"
  files.map! {|n| File.join(tag, n)} if tag
  set = block.binding.eval("proc {|match| $~ = match}")
  IO.popen([cmd, *files]) do |f|
    f.grep(pat) do |s|
      set[$~]
      yield s
    end
  end
end
tag(name)
# File tool/vcs.rb, line 217
def tag(name)
  url + "tags/#{name}"
end
trunk()
# File tool/vcs.rb, line 221
def trunk
  url + "trunk"
end
url()
# File tool/vcs.rb, line 196
def url
  unless @url
    url = get_info[/<root>(.*)<\/root>/, 1]
    @url = URI.parse(url+"/") if url
  end
  @url
end
wcroot()
# File tool/vcs.rb, line 204
def wcroot
  unless @wcroot
    info = get_info
    @wcroot = info[/<wcroot-abspath>(.*)<\/wcroot-abspath>/, 1]
    @wcroot ||= self.class.search_root(@srcdir)
  end
  @wcroot
end