Implements the Capistrano SCM interface for the Perforce revision control system (www.perforce.com).
Returns the command that will sync the given revision to the given destination directory. The perforce client has a fixed destination so the files must be copied from there to their intended resting place.
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 27 27: def checkout(revision, destination) 28: p4_sync(revision, destination, p4sync_flags) 29: end
Returns the command that will do an “p4 diff2” for the two revisions.
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 46 46: def diff(from, to=head) 47: scm authentication, :diff2, "-u -db", "//#{p4client}/...#{rev_no(from)}", "//#{p4client}/...#{rev_no(to)}" 48: end
Returns the command that will sync the given revision to the given destination directory. The perforce client has a fixed destination so the files must be copied from there to their intended resting place.
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 41 41: def export(revision, destination) 42: p4_sync(revision, destination, p4sync_flags) 43: 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/perforce.rb, line 69 69: def handle_data(state, stream, text) 70: case text 71: when /\(P4PASSWD\) invalid or unset\./ 72: raise Capistrano::Error, "scm_password (or p4passwd) is incorrect or unset" 73: when /Can.t create a new user.*/ 74: raise Capistrano::Error, "scm_username (or p4user) is incorrect or unset" 75: when /Perforce client error\:/ 76: raise Capistrano::Error, "p4port is incorrect or unset" 77: when /Client \'[\w\-\_\.]+\' unknown.*/ 78: raise Capistrano::Error, "p4client is incorrect or unset" 79: end 80: end
Returns a “p4 changes” command for the two revisions.
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 51 51: def log(from=1, to=head) 52: scm authentication, :changes, "-s submitted", "//#{p4client}/...#{rev_no(from)},#{rev_no(to)}" 53: end
Increments the given revision number and returns it.
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 62 62: def next_revision(revision) 63: revision.to_i + 1 64: end
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 55 55: def query_revision(revision) 56: return revision if revision.to_s =~ /^\d+$/ 57: command = scm(authentication, :changes, "-s submitted", "-m 1", "//#{p4client}/...#{rev_no(revision)}") 58: yield(command)[/Change (\d+) on/, 1] 59: end
Returns the command that will sync the given revision to the given destination directory. The perforce client has a fixed destination so the files must be copied from there to their intended resting place.
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 34 34: def sync(revision, destination) 35: p4_sync(revision, destination, p4sync_flags) 36: end
Builds the set of authentication switches that perforce understands.
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 85 85: def authentication 86: [ p4port && "-p #{p4port}", 87: p4user && "-u #{p4user}", 88: p4passwd && "-P #{p4passwd}", 89: p4client && "-c #{p4client}" ].compact.join(" ") 90: end
Returns the command that will sync the given revision to the given destination directory with specific options. The perforce client has a fixed destination so the files must be copied from there to their intended resting place.
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 96 96: def p4_sync(revision, destination, options="") 97: scm authentication, :sync, options, "#{rev_no(revision)}", "&& cp -rf #{p4client_root} #{destination}" 98: end
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 100 100: def p4client 101: variable(:p4client) 102: end
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 120 120: def p4client_root 121: variable(:p4client_root) || "`#{command} #{authentication} client -o | grep ^Root | cut -f2`" 122: end
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 112 112: def p4passwd 113: variable(:p4passwd) || variable(:scm_password) 114: end
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 104 104: def p4port 105: variable(:p4port) 106: end
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 116 116: def p4sync_flags 117: variable(:p4sync_flags) || "-f" 118: end
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 108 108: def p4user 109: variable(:p4user) || variable(:scm_username) 110: end
# File lib/capistrano/recipes/deploy/scm/perforce.rb, line 124 124: def rev_no(revision) 125: if variable(:p4_label) 126: p4_label = if variable(:p4_label) =~ /\A@/ 127: variable(:p4_label) 128: else 129: "@#{variable(:p4_label)}" 130: end 131: return p4_label 132: end 133: 134: case revision.to_s 135: when "head" 136: "#head" 137: when /^\d+/ 138: "@#{revision}" 139: else 140: revision 141: end 142: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.