Class: Capistrano::Deploy::SCM::Cvs

Inherits:
Base
  • Object
show all
Defined in:
lib/capistrano/recipes/deploy/scm/cvs.rb

Overview

Implements the Capistrano SCM interface for the CVS revision control system.

Instance Attribute Summary

Attributes inherited from Base

#configuration

Instance Method Summary collapse

Methods inherited from Base

#command, default_command, #initialize, #local, #local?, #next_revision, #scm

Constructor Details

This class inherits a constructor from Capistrano::Deploy::SCM::Base

Instance Method Details

#checkout(revision, destination) ⇒ Object

Returns the command that will check out the given revision to the given destination.



22
23
24
25
26
# File 'lib/capistrano/recipes/deploy/scm/cvs.rb', line 22

def checkout(revision, destination)
  [ prep_destination(destination),
    scm(verbose, cvs_root, :checkout, cvs_revision(revision), cvs_destination(destination), variable(:scm_module))
  ].join(' && ')
end

#diff(from, to = nil) ⇒ Object

Returns the command that will do an “cvs diff” for the two revisions.



45
46
47
48
49
50
51
52
53
# File 'lib/capistrano/recipes/deploy/scm/cvs.rb', line 45

def diff(from, to=nil)
  rev_type = revision_type(from)
  if rev_type == :date
    range_args = "-D '#{from}' -D '#{to || 'now'}'"
  else
    range_args = "-r '#{from}' -r '#{to || head}'"
  end
  scm cvs_root, :diff, range_args
end

#export(revision, destination) ⇒ Object

Returns the command that will do an “cvs export” of the given revision to the given destination.



38
39
40
41
42
# File 'lib/capistrano/recipes/deploy/scm/cvs.rb', line 38

def export(revision, destination)
  [ prep_destination(destination),
    scm(verbose, cvs_root, :export, cvs_revision(revision), cvs_destination(destination), variable(:scm_module))
  ].join(' && ')
end

#handle_data(state, stream, text) ⇒ Object

Determines what the response should be for a particular bit of text from the SCM. Password prompts, connection requests, passphrases, etc. are handled here.



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/capistrano/recipes/deploy/scm/cvs.rb', line 81

def handle_data(state, stream, text)
  logger.info "[#{stream}] #{text}"
  case text
  when /\bpassword.*:/i
    # prompting for a password
    "#{variable(:scm_password) || variable(:password)}\n"
  when %r{\(yes/no\)}
    # let's be agreeable...
    "yes\n"
  end
end

#headObject

CVS understands ‘HEAD’ to refer to the latest revision in the repository.



16
17
18
# File 'lib/capistrano/recipes/deploy/scm/cvs.rb', line 16

def head
  "HEAD"
end

#log(from, to = nil) ⇒ Object

Returns an “cvs log” command for the two revisions.



56
57
58
59
60
61
62
63
64
# File 'lib/capistrano/recipes/deploy/scm/cvs.rb', line 56

def log(from, to=nil)
  rev_type = revision_type(from)
  if rev_type == :date
    range_arg = "-d '#{from}<#{to || 'now'}'"
  else
    range_arg = "-r '#{from}:#{to || head}'"
  end
  scm cvs_root, :log, range_arg
end

#query_revision(revision) ⇒ Object

Unfortunately, cvs doesn’t support the concept of a revision number like subversion and other SCM’s do. For now, we’ll rely on getting the timestamp of the latest checkin under the revision that’s passed to us.



69
70
71
72
73
74
75
76
# File 'lib/capistrano/recipes/deploy/scm/cvs.rb', line 69

def query_revision(revision)
  return revision if revision_type(revision) == :date
  revision = yield(scm(cvs_root, :log, "-r#{revision}")).
               grep(/^date:/).
               map { |line| line[/^date: (.*?);/, 1] }.
               sort.last + " UTC"
  return revision
end

#sync(revision, destination) ⇒ Object

Returns the command that will do an “cvs update” to the given revision, for the working copy at the given destination.



30
31
32
33
34
# File 'lib/capistrano/recipes/deploy/scm/cvs.rb', line 30

def sync(revision, destination)
  [ prep_destination(destination),
    scm(verbose, cvs_root, :update, cvs_revision(revision), cvs_destination(destination))
  ].join(' && ')
end