Class: Capistrano::Deploy::SCM::Perforce
- Defined in:
- lib/capistrano/recipes/deploy/scm/perforce.rb
Overview
Implements the Capistrano SCM interface for the Perforce revision control system (www.perforce.com).
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#checkout(revision, destination) ⇒ Object
Returns the command that will sync the given revision to the given destination directory.
-
#diff(from, to = head) ⇒ Object
Returns the command that will do an “p4 diff2” for the two revisions.
-
#export(revision, destination) ⇒ Object
Returns the command that will sync the given revision to the given destination directory.
-
#handle_data(state, stream, text) ⇒ Object
Determines what the response should be for a particular bit of text from the SCM.
-
#head ⇒ Object
Perforce understands ‘#head’ to refer to the latest revision in the depot.
-
#log(from = 1, to = head) ⇒ Object
Returns a “p4 changes” command for the two revisions.
- #query_revision(revision) ⇒ Object
-
#sync(revision, destination) ⇒ Object
Returns the command that will sync the given revision to the given destination directory.
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 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.
27 28 29 |
# File 'lib/capistrano/recipes/deploy/scm/perforce.rb', line 27 def checkout(revision, destination) p4_sync(revision, destination, p4sync_flags) end |
#diff(from, to = head) ⇒ Object
Returns the command that will do an “p4 diff2” for the two revisions.
46 47 48 |
# File 'lib/capistrano/recipes/deploy/scm/perforce.rb', line 46 def diff(from, to=head) scm authentication, :diff2, "-u -db", "//#{p4client}/...#{rev_no(from)}", "//#{p4client}/...#{rev_no(to)}" end |
#export(revision, destination) ⇒ Object
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.
41 42 43 |
# File 'lib/capistrano/recipes/deploy/scm/perforce.rb', line 41 def export(revision, destination) p4_sync(revision, destination, p4sync_flags) 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.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/capistrano/recipes/deploy/scm/perforce.rb', line 64 def handle_data(state, stream, text) case text when /\(P4PASSWD\) invalid or unset\./i raise Capistrano::Error, "scm_password (or p4passwd) is incorrect or unset" when /Can.t create a new user.*/i raise Capistrano::Error, "scm_username (or p4user) is incorrect or unset" when /Perforce client error\:/i raise Capistrano::Error, "p4port is incorrect or unset" when /Client \'[\w\-\_\.]+\' unknown.*/i raise Capistrano::Error, "p4client is incorrect or unset" end end |
#head ⇒ Object
Perforce understands ‘#head’ to refer to the latest revision in the depot.
20 21 22 |
# File 'lib/capistrano/recipes/deploy/scm/perforce.rb', line 20 def head 'head' end |
#log(from = 1, to = head) ⇒ Object
Returns a “p4 changes” command for the two revisions.
51 52 53 |
# File 'lib/capistrano/recipes/deploy/scm/perforce.rb', line 51 def log(from=1, to=head) scm authentication, :changes, "-s submitted", "//#{p4client}/...#{rev_no(from)},#(rev_no(to)}" end |
#query_revision(revision) ⇒ Object
55 56 57 58 59 |
# File 'lib/capistrano/recipes/deploy/scm/perforce.rb', line 55 def query_revision(revision) return revision if revision.to_s =~ /^\d+$/ command = scm(authentication, :changes, "-s submitted", "-m 1", "//#{p4client}/...#{rev_no(revision)}") yield(command)[/Change (\d+) on/, 1] end |
#sync(revision, destination) ⇒ Object
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.
34 35 36 |
# File 'lib/capistrano/recipes/deploy/scm/perforce.rb', line 34 def sync(revision, destination) p4_sync(revision, destination, p4sync_flags) end |