Method: CodeCache::Repo::SVN#checkout

Defined in:
lib/code_cache/repo/svn.rb

#checkout(revision, destination, branch = nil) ⇒ Object

Checkout a particular revision from the repo into the destination Caches the checkout in the process



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/code_cache/repo/svn.rb', line 12

def checkout( revision, destination, branch=nil )
 
  puts "Checking out branch in not supported for SVN" if branch
  
  if revision != :head
    raise "Checking out revisions other than head currently not supported"
  end
  
  cache_destination = location_in_cache(revision)
  
  # Try and copy into the cache first
  begin
    perform_cache_checkout_or_update(cache_destination)
    FileUtils.mkdir_p(destination)
    
    FileUtils.cp_r(cache_destination+'/.', destination)
    # Ensure the final copy is consistent
    raise CopyError if !Dir.exist?(destination)
    output = perform_update(destination)
    if !output[:status]
      raise UpdateError.new(output)
    end
    
  rescue => e
    puts "Unhandled randomness: " + e.to_s + ' - ' + e.backtrace.to_s
    # If we can't copy into the cache, copy directly to the destination
    perform_checkout(destination)
  end
  
  true
end