Implements the Capistrano SCM interface for the CVS revision control system.
Returns the command that will check out the given revision to the given destination.
# File lib/capistrano/recipes/deploy/scm/cvs.rb, line 22 22: def checkout(revision, destination) 23: [ prep_destination(destination), 24: scm(verbose, cvs_root, :checkout, cvs_revision(revision), cvs_destination(destination), variable(:scm_module)) 25: ].join(' && ') 26: end
Returns the command that will do an “cvs diff” for the two revisions.
# File lib/capistrano/recipes/deploy/scm/cvs.rb, line 45 45: def diff(from, to=nil) 46: rev_type = revision_type(from) 47: if rev_type == :date 48: range_args = "-D '#{from}' -D '#{to || 'now'}'" 49: else 50: range_args = "-r '#{from}' -r '#{to || head}'" 51: end 52: scm cvs_root, :diff, range_args 53: end
Returns the command that will do an “cvs export” of the given revision to the given destination.
# File lib/capistrano/recipes/deploy/scm/cvs.rb, line 38 38: def export(revision, destination) 39: [ prep_destination(destination), 40: scm(verbose, cvs_root, :export, cvs_revision(revision), cvs_destination(destination), variable(:scm_module)) 41: ].join(' && ') 42: end
Determines what the response should be for a particular bit of text from the SCM. Password prompts, connection requests, passphrases, etc. are handled here.
# File lib/capistrano/recipes/deploy/scm/cvs.rb, line 82 82: def handle_data(state, stream, text) 83: logger.info "[#{stream}] #{text}" 84: case text 85: when /\bpassword.*:/ 86: # prompting for a password 87: "#{variable(:scm_password) || variable(:password)}\n" 88: when %{\(yes/no\)} 89: # let's be agreeable... 90: "yes\n" 91: end 92: end
CVS understands ‘HEAD’ to refer to the latest revision in the repository.
# File lib/capistrano/recipes/deploy/scm/cvs.rb, line 16 16: def head 17: "HEAD" 18: end
Returns an “cvs log” command for the two revisions.
# File lib/capistrano/recipes/deploy/scm/cvs.rb, line 56 56: def log(from, to=nil) 57: rev_type = revision_type(from) 58: if rev_type == :date 59: range_arg = "-d '#{from}<#{to || 'now'}'" 60: else 61: range_arg = "-r '#{from}:#{to || head}'" 62: end 63: scm cvs_root, :log, range_arg 64: end
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.
# File lib/capistrano/recipes/deploy/scm/cvs.rb, line 69 69: def query_revision(revision) 70: return revision if revision_type(revision) == :date 71: revision = yield(scm(cvs_root, :log, "-r#{revision}")). 72: split("\n"). 73: select { |line| line =~ /^date:/ }. 74: map { |line| line[/^date: (.*?);/, 1] }. 75: sort.last + " UTC" 76: return revision 77: end
Returns the command that will do an “cvs update” to the given revision, for the working copy at the given destination.
# File lib/capistrano/recipes/deploy/scm/cvs.rb, line 30 30: def sync(revision, destination) 31: [ prep_destination(destination), 32: scm(verbose, cvs_root, :update, cvs_revision(revision), cvs_destination(destination)) 33: ].join(' && ') 34: end
Constructs the destination dir command-line option
# File lib/capistrano/recipes/deploy/scm/cvs.rb, line 104 104: def cvs_destination(destination) 105: dest = "" 106: if destination 107: dest_parts = destination.split(/\//); 108: dest << "-d #{dest_parts.pop}" 109: end 110: dest 111: end
constructs the appropriate command-line switch for specifying a “revision” in CVS. This could be a tag, branch, revision (i.e. 1.3) or a date (to be used with -d)
# File lib/capistrano/recipes/deploy/scm/cvs.rb, line 124 124: def cvs_revision(rev) 125: revision = "" 126: revision << case revision_type(rev) 127: when :date 128: "-D \"#{rev}\"" if revision_type(rev) == :date 129: when :revision 130: "-r #{rev}" 131: else 132: "-r #{head}" 133: end 134: return revision 135: end
Constructs the CVSROOT command-line option
# File lib/capistrano/recipes/deploy/scm/cvs.rb, line 97 97: def cvs_root 98: root = "" 99: root << "-d #{repository} " if repository 100: root 101: end
# File lib/capistrano/recipes/deploy/scm/cvs.rb, line 143 143: def prep_destination(destination) 144: dest_parts = destination.split(/\//); 145: checkout_dir = dest_parts.pop 146: dest = dest_parts.join('/') 147: "mkdir -p #{ dest } && cd #{ dest }" 148: end
attempts to guess what type of revision we’re working with
# File lib/capistrano/recipes/deploy/scm/cvs.rb, line 114 114: def revision_type(rev) 115: return :date if rev =~ /^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2} UTC$/ # i.e 2007-05-15 08:13:25 UTC 116: return :date if rev =~ /^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}$/ # i.e 2007-05-15 08:13:25 117: return :revision if rev =~ /^\d/ # i.e. 1.2.1 118: return :tag # i.e. RELEASE_1_2 119: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.