Class RSCM::P4Client
In: lib/rscm/scm/perforce.rb
Parent: Object

Understands operations against a client-workspace

Methods

add   add_all   checkout   diff   edit   move   name   new   revisions   submit   uptodate?  

Classes and Modules

Class RSCM::P4Client::P4Changelist

Constants

DATE_FORMAT = "%Y/%m/%d:%H:%M:%S"
STATUS = { "add" => RevisionFile::ADDED, "edit" => RevisionFile::MODIFIED, "delete" => RevisionFile::DELETED }
FileSpec = Struct.new(:path, :revision, :status)

Public Class methods

[Source]

     # File lib/rscm/scm/perforce.rb, line 244
244:     def initialize(checkout_dir, name, port, user, pwd)
245:       @checkout_dir, @name, @port, @user, @pwd = checkout_dir, name, port, user, pwd
246:     end

Public Instance methods

[Source]

     # File lib/rscm/scm/perforce.rb, line 268
268:     def add(relative_path)
269:       add_file(rootdir + "/" + relative_path)
270:     end

[Source]

     # File lib/rscm/scm/perforce.rb, line 284
284:     def add_all(files)
285:       files.each {|file| add_file(file)}
286:     end

[Source]

     # File lib/rscm/scm/perforce.rb, line 296
296:     def checkout(to_identifier)
297:       cmd = to_identifier.nil? ? "sync" : "sync //...@#{to_identifier}"
298:       checked_out_files = []
299:       p4(cmd).collect do |output|
300:         #puts "output: '#{output}'"
301:         if(output =~ /.* - (added as|updating|deleted as) #{rootdir}[\/|\\](.*)/)
302:           path = $2.gsub(/\\/, "/")
303:           checked_out_files << path
304:           yield path if block_given?
305:         end
306:       end
307:       checked_out_files
308:     end

[Source]

     # File lib/rscm/scm/perforce.rb, line 310
310:     def diff(r)
311:       path = File.expand_path(@checkout_dir + "/" + r.path)
312:       from = r.previous_native_revision_identifier
313:       to = r.native_revision_identifier
314:       cmd = p4cmd("diff2 -du #{path}@#{from} #{path}@#{to}")
315:       Better.popen(cmd) do |io|
316:         return(yield(io))
317:       end
318:     end

[Source]

     # File lib/rscm/scm/perforce.rb, line 263
263:     def edit(file)
264:       file = File.expand_path(file)
265:       p4("edit #{file}")
266:     end

www.perforce.com/perforce/doc.051/manuals/cmdref/rename.html#1040665

[Source]

     # File lib/rscm/scm/perforce.rb, line 273
273:     def move(checkout_dir, relative_src, relative_dest)
274:       with_working_dir(checkout_dir) do
275:         absolute_src = PathConverter.filepath_to_nativepath(relative_src, true)
276:         absolute_dest = PathConverter.filepath_to_nativepath(relative_dest, true)
277:         FileUtils.mv(absolute_src, absolute_dest)
278:         p4("integrate #{absolute_src} #{absolute_dest}")
279:         p4("delete #{absolute_src}")
280:       end
281: #      p4("submit #{absolute_src}")
282:     end

[Source]

     # File lib/rscm/scm/perforce.rb, line 259
259:     def name
260:       @name
261:     end

[Source]

     # File lib/rscm/scm/perforce.rb, line 252
252:     def revisions(from_identifier, to_identifier)
253:       revisions = changelists(from_identifier, to_identifier).collect {|changelist| to_revision(changelist)}
254:       # We have to reverse the revisions in order to make them appear in chronological order,
255:       # P4 lists the newest ones first.
256:       Revisions.new(revisions).reverse
257:     end

[Source]

     # File lib/rscm/scm/perforce.rb, line 288
288:     def submit(comment)
289:       IO.popen(p4cmd("submit -i"), "w+") do |io|
290:         io.puts(submitspec(comment))
291:         io.close_write
292:         io.each_line {|progress| debug progress}
293:       end
294:     end

[Source]

     # File lib/rscm/scm/perforce.rb, line 248
248:     def uptodate?
249:       p4("sync -n").empty?
250:     end

[Validate]