Class: RSCM::P4Client
- Inherits:
-
Object
show all
- Defined in:
- lib/rscm/scm/perforce.rb
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.
244
245
246
|
# File 'lib/rscm/scm/perforce.rb', line 244
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
268
269
270
|
# File 'lib/rscm/scm/perforce.rb', line 268
def add(relative_path)
add_file(rootdir + "/" + relative_path)
end
|
#add_all(files) ⇒ Object
284
285
286
|
# File 'lib/rscm/scm/perforce.rb', line 284
def add_all(files)
files.each {|file| add_file(file)}
end
|
#checkout(to_identifier) ⇒ Object
296
297
298
299
300
301
302
303
304
305
306
307
308
|
# File 'lib/rscm/scm/perforce.rb', line 296
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
|
#diff(r) ⇒ Object
310
311
312
313
314
315
316
317
318
|
# File 'lib/rscm/scm/perforce.rb', line 310
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
263
264
265
266
|
# File 'lib/rscm/scm/perforce.rb', line 263
def edit(file)
file = File.expand_path(file)
p4("edit #{file}")
end
|
#move(checkout_dir, relative_src, relative_dest) ⇒ Object
273
274
275
276
277
278
279
280
281
282
|
# File 'lib/rscm/scm/perforce.rb', line 273
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
|
#name ⇒ Object
259
260
261
|
# File 'lib/rscm/scm/perforce.rb', line 259
def name
@name
end
|
#revisions(from_identifier, to_identifier) ⇒ Object
252
253
254
255
256
257
|
# File 'lib/rscm/scm/perforce.rb', line 252
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
288
289
290
291
292
293
294
|
# File 'lib/rscm/scm/perforce.rb', line 288
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
248
249
250
|
# File 'lib/rscm/scm/perforce.rb', line 248
def uptodate?
p4("sync -n").empty?
end
|