Class: Drupid::DownloadStrategy::Subversion

Inherits:
Base
  • Object
show all
Defined in:
lib/drupid/download_strategy.rb

Instance Attribute Summary

Attributes inherited from Base

#dest, #name, #staged_path, #url

Instance Method Summary collapse

Methods included from Utils

#blah, #bzr, #compare_paths, #curl, #cvs, #debug, #dont_debug, #git, #hg, #ignore_interrupts, #interactive_shell, #odie, #ofail, #ohai, #owarn, #runBabyRun, #svn, #tempdir, #uncompress, #which, #writeFile

Constructor Details

#initialize(url, dest, name, download_specs = {}) ⇒ Subversion

Returns a new instance of Subversion.



350
351
352
353
# File 'lib/drupid/download_strategy.rb', line 350

def initialize  url, dest, name, download_specs = {}
  super
  @co = @dest + @name
end

Instance Method Details

#fetchObject



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/drupid/download_strategy.rb', line 355

def fetch
  @url.sub!(/^svn\+/, '') if @url =~ %r[^svn\+http://]
  blah "Checking out #{@url}"
  if @specs.has_key?('revision')
    fetch_repo @co, @url, @specs['revision']
    # elsif @specs.has_key?('revisions')
    #   # nil is OK for main_revision, as fetch_repo will then get latest
    #   main_revision = @ref.delete :trunk
    #   fetch_repo @co, @url, main_revision, true
    #
    #   get_externals do |external_name, external_url|
    #     fetch_repo @co+external_name, external_url, @ref[external_name], true
    #   end
  else
    fetch_repo @co, @url
  end
end

#fetch_repo(target, url, revision = nil, ignore_externals = false) ⇒ Object



389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# File 'lib/drupid/download_strategy.rb', line 389

def fetch_repo target, url, revision=nil, ignore_externals=false
  # Use "svn up" when the repository already exists locally.
  # This saves on bandwidth and will have a similar effect to verifying the
  # cache as it will make any changes to get the right revision.
  svncommand = target.exist? ? 'up' : 'checkout'
  args = [svncommand]
  args << '--non-interactive' unless @specs.has_key?('interactive') and 'true' == @specs.has_key?('interactive')
  args << '--trust-server-cert'
  # SVN shipped with XCode 3.1.4 can't force a checkout.
  #args << '--force' unless MacOS.leopard? and svn == '/usr/bin/svn'
  args << url if !target.exist?
  args << target
  args << '-r' << revision if revision
  args << '--ignore-externals' if ignore_externals
  svn(*args)
end

#get_externalsObject



381
382
383
384
385
386
387
# File 'lib/drupid/download_strategy.rb', line 381

def get_externals
  output = svn 'propget', 'svn:externals', @url
  output.chomp.each_line do |line|
    name, url = line.split(/\s+/)
    yield name, url
  end
end

#stage(wd = @dest) ⇒ Object



373
374
375
376
377
378
379
# File 'lib/drupid/download_strategy.rb', line 373

def stage wd = @dest
  fetch unless @co.exist?
  dont_debug { wd.mkpath }
  debug "Staging into #{wd}"
  target = wd + @co.basename
  svn 'export', '--force', @co, target
end