Parent

Files

RSCM::Perforce

Constants

CHANGELIST_PATTERN

Doesn’t work for empty messages, (Like 21358 in Aslak’s P4 repo)

CHANGELIST_PATTERN_NO_MSG

But this one does

DATE_FORMAT
STATES

Attributes

password[RW]
username[RW]
view[RW]

Public Instance Methods

destroy_working_copy(options={}) click to toggle source
# File lib/rscm/scm/perforce.rb, line 117
def destroy_working_copy(options={})
  execute("p4 #{p4_opts(false)} client -d #{client_name}", options)
end
diff() click to toggle source
# File lib/rscm/scm/perforce.rb, line 129
def diff
#p4 diff2 //depot/trunk/build.xml@26405 //depot/trunk/build.xml@26409

end
installed?() click to toggle source
# File lib/rscm/scm/perforce.rb, line 33
def installed?
  begin
    execute("p4 info", {}) 
    true
  rescue
    false
  end
end
open(revision_file, options={}, &block) click to toggle source
# File lib/rscm/scm/perforce.rb, line 121
def open(revision_file, options={}, &block)
  path = @view.gsub(/\.\.\./, revision_file.path) # + "@" + revision_file.native_revision_identifier

  cmd = "p4 #{p4_opts(false)} print -q #{path}"
  execute(cmd, options) do |io|
    block.call io
  end
end
revisions(from_identifier=Time.new.utc, options={}) click to toggle source
# File lib/rscm/scm/perforce.rb, line 42
def revisions(from_identifier=Time.new.utc, options={})
  raise "from_identifer cannot be nil" if from_identifier.nil?
  set_utc_offset(options)
  view_as_regexp = "^" + @view.gsub(/\.\.\./, "(.*)")
  relative_path_pattern = Regexp.new(view_as_regexp)

  from_identifier = Time.epoch unless from_identifier
  from_identifier = Time.epoch if (from_identifier.is_a? Time and from_identifier < Time.epoch)
  from = revision_spec(from_identifier + 1) # We have to add 1 because of the contract of this method.


  to_identifier = options[:to_identifier] ? options[:to_identifier] : Time.infinity
  to = revision_spec(to_identifier - 1) # We have to subtract 1 because of the contract of this method.


  cmd = "p4 #{p4_opts(false)} changes #{@view}@#{from},#{to}"
  revisions = Revisions.new
  revisions.cmd = cmd if store_revisions_command?

  changes = execute(cmd, options) do |io|
    io.read
  end

  changes.each do |line|
    revision = nil
    identifier = line.match(/^Change (\d+)/)[1].to_i

    execute("p4 #{p4_opts(false)} describe -s #{identifier}", options) do |io|
      log = io.read

      if log =~ CHANGELIST_PATTERN
        developer, time, message, files = $1, $2, $3, $4
      elsif log =~ CHANGELIST_PATTERN_NO_MSG
        developer, time, files = $1, $2, $3
      else
        puts "PARSE ERROR:"
        puts log
        puts "\nDIDN'T MATCH:"
        puts CHANGELIST_PATTERN
      end

      # The parsed time doesn't have timezone info. We'll tweak it.

      time = Time.parse(time + " UTC") - @utc_offset

      files.each_line do |line|
        if line =~ /^\.\.\. (\/\/.+)#(\d+) (.+)/
          depot_path = $1
          file_identifier = $2.to_i
          state = $3.strip
          if(STATES[state])
            if(depot_path =~ relative_path_pattern)
              relative_path = $1

              if revision.nil?
                revision = Revision.new
                revision.identifier = identifier
                revision.developer = developer
                revision.message = message
                revision.time = time
                revisions.add revision
              end

              file = RevisionFile.new
              file.path = relative_path
              file.native_revision_identifier = file_identifier
              file.previous_native_revision_identifier = file.native_revision_identifier-1
              file.status = STATES[state]
              revision.add file
            end
          end
        end
      end
    end
  end
  revisions
end

Protected Instance Methods

checkout_silent(to_identifier, options) click to toggle source
# File lib/rscm/scm/perforce.rb, line 135
def checkout_silent(to_identifier, options)
  checkout_dir = PathConverter.filepath_to_nativepath(@checkout_dir, false)
  FileUtils.mkdir_p(@checkout_dir)
  
  ensure_client(options)
  execute("p4 #{p4_opts} sync #{@view}@#{to_identifier}", options)
end
ignore_paths() click to toggle source
# File lib/rscm/scm/perforce.rb, line 143
def ignore_paths
  []
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.