Class: RSCM::P4Client
Overview
Understands operations against a client-workspace
Defined Under Namespace
Classes: FileSpec, P4Changelist
Constant Summary
collapse
- DATE_FORMAT =
"%Y/%m/%d:%H:%M:%S"
- STATUS =
{ "add" => RevisionFile::ADDED, "edit" => RevisionFile::MODIFIED, "delete" => RevisionFile::DELETED }
Instance Method Summary
collapse
Constructor Details
#initialize(checkout_dir, name, port, user, pwd) ⇒ P4Client
Returns a new instance of P4Client.
250
251
252
|
# File 'lib/rscm/scm/perforce.rb', line 250
def initialize(checkout_dir, name, port, user, pwd)
@checkout_dir, @name, @port, @user, @pwd = checkout_dir, name, port, user, pwd
end
|
Instance Method Details
#add(relative_path) ⇒ Object
274
275
276
|
# File 'lib/rscm/scm/perforce.rb', line 274
def add(relative_path)
add_file(rootdir + "/" + relative_path)
end
|
#add_all(files) ⇒ Object
290
291
292
|
# File 'lib/rscm/scm/perforce.rb', line 290
def add_all(files)
files.each {|file| add_file(file)}
end
|
#checkout(to_identifier) ⇒ Object
302
303
304
305
306
307
308
309
310
311
312
313
314
|
# File 'lib/rscm/scm/perforce.rb', line 302
def checkout(to_identifier)
cmd = to_identifier.nil? ? "sync" : "sync //...@#{to_identifier}"
checked_out_files = []
p4(cmd).collect do |output|
if(output =~ /.* - (added as|updating|deleted as) #{rootdir}[\/|\\](.*)/)
path = $2.gsub(/\\/, "/")
checked_out_files << path
yield path if block_given?
end
end
checked_out_files
end
|
316
317
318
319
320
321
322
323
324
|
# File 'lib/rscm/scm/perforce.rb', line 316
def diff(r)
path = File.expand_path(@checkout_dir + "/" + r.path)
from = r.previous_native_revision_identifier
to = r.native_revision_identifier
cmd = p4cmd("diff2 -du #{path}@#{from} #{path}@#{to}")
Better.popen(cmd) do |io|
return(yield(io))
end
end
|
#edit(file) ⇒ Object
269
270
271
272
|
# File 'lib/rscm/scm/perforce.rb', line 269
def edit(file)
file = File.expand_path(file)
p4("edit #{file}")
end
|
#move(checkout_dir, relative_src, relative_dest) ⇒ Object
279
280
281
282
283
284
285
286
287
288
|
# File 'lib/rscm/scm/perforce.rb', line 279
def move(checkout_dir, relative_src, relative_dest)
with_working_dir(checkout_dir) do
absolute_src = PathConverter.filepath_to_nativepath(relative_src, true)
absolute_dest = PathConverter.filepath_to_nativepath(relative_dest, true)
FileUtils.mv(absolute_src, absolute_dest)
p4("integrate #{absolute_src} #{absolute_dest}")
p4("delete #{absolute_src}")
end
end
|
265
266
267
|
# File 'lib/rscm/scm/perforce.rb', line 265
def name
@name
end
|
#revisions(from_identifier, to_identifier) ⇒ Object
258
259
260
261
262
263
|
# File 'lib/rscm/scm/perforce.rb', line 258
def revisions(from_identifier, to_identifier)
revisions = changelists(from_identifier, to_identifier).collect {|changelist| to_revision(changelist)}
Revisions.new(revisions).reverse
end
|
#submit(comment) ⇒ Object
294
295
296
297
298
299
300
|
# File 'lib/rscm/scm/perforce.rb', line 294
def submit()
IO.popen(p4cmd("submit -i"), "w+") do |io|
io.puts(submitspec())
io.close_write
io.each_line {|progress| debug progress}
end
end
|
#uptodate? ⇒ Boolean
254
255
256
|
# File 'lib/rscm/scm/perforce.rb', line 254
def uptodate?
p4("sync -n").empty?
end
|