Class Index [+]

Quicksearch

Capistrano::Deploy::SCM::Perforce

Implements the Capistrano SCM interface for the Perforce revision control system (www.perforce.com).

Public Instance Methods

checkout(revision, destination) click to toggle source

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
diff(from, to=head) click to toggle source

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
export(revision, destination) click to toggle source

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
handle_data(state, stream, text) click to toggle source

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
head() click to toggle source

Perforce understands ‘#’ to refer to the latest revision in the depot.

    # File lib/capistrano/recipes/deploy/scm/perforce.rb, line 20
20:         def head
21:           'head'
22:         end
log(from=1, to=head) click to toggle source

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
next_revision(revision) click to toggle source

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
query_revision(revision) click to toggle source
    # 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
sync(revision, destination) click to toggle source

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

Private Instance Methods

authentication() click to toggle source

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
p4_sync(revision, destination, options="") click to toggle source

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
p4client() click to toggle source
     # File lib/capistrano/recipes/deploy/scm/perforce.rb, line 100
100:           def p4client
101:             variable(:p4client)
102:           end
p4client_root() click to toggle source
     # 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
p4passwd() click to toggle source
     # File lib/capistrano/recipes/deploy/scm/perforce.rb, line 112
112:           def p4passwd
113:             variable(:p4passwd) || variable(:scm_password)
114:           end
p4port() click to toggle source
     # File lib/capistrano/recipes/deploy/scm/perforce.rb, line 104
104:           def p4port
105:             variable(:p4port)
106:           end
p4sync_flags() click to toggle source
     # File lib/capistrano/recipes/deploy/scm/perforce.rb, line 116
116:           def p4sync_flags
117:             variable(:p4sync_flags) || "-f"
118:           end
p4user() click to toggle source
     # File lib/capistrano/recipes/deploy/scm/perforce.rb, line 108
108:           def p4user
109:             variable(:p4user) || variable(:scm_username)
110:           end
rev_no(revision) click to toggle source
     # 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.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.