Parent

Files

RSCM::ClearCase

Attributes

config_spec[RW]
stgloc[RW]
stream[RW]
tag[RW]

Public Class Methods

new(stream=nil, stgloc=nil, tag=nil, config_spec=DEFAULT_CONFIG_SPEC) click to toggle source
# File lib/rscm/scm/clearcase.rb, line 23
def initialize(stream=nil, stgloc=nil, tag=nil, config_spec=DEFAULT_CONFIG_SPEC)
  @stream, @stgloc, @tag, @config_spec = stream, stgloc, tag, config_spec
end

Public Instance Methods

catcs(options={}) click to toggle source
# File lib/rscm/scm/clearcase.rb, line 115
def catcs(options={})
  Dir.chdir(checkout_dir) do
    catcs_cmd = "cleartool catcs"
    execute(catcs_cmd, options) do |io|
      yield io
    end
  end
end
checked_out?() click to toggle source
# File lib/rscm/scm/clearcase.rb, line 74
def checked_out?
  !Dir["#{checkout_dir}/*"].empty?
end
destroy_working_copy(options={}) click to toggle source
# File lib/rscm/scm/clearcase.rb, line 78
def destroy_working_copy(options={})
  execute("cleartool rmview #{checkout_dir}", options) do |io|
    io.read
  end
end
import_central(options={}) click to toggle source
# File lib/rscm/scm/clearcase.rb, line 84
def import_central(options={})
  execute("clearfsimport -recurse -nsetevent #{options[:dir]} #{checkout_dir}", options) do |io|
    io.read
  end
end
load_rules() click to toggle source

What's loaded into view

# File lib/rscm/scm/clearcase.rb, line 133
def load_rules
  result = []
  catcs do |io|
    io.each_line do |line|
      if(line =~ /^load[\s]*(.*)$/)
        return result << $1
      end
    end
  end
  result
end
mkview!(options={}) click to toggle source

Non-RSCM API methods

# File lib/rscm/scm/clearcase.rb, line 92
def mkview!(options={})
   # Create view (working copy)
   mkview_cmd = "cleartool mkview -snapshot -stream #{@stream} -stgloc #{@stgloc} -tag #{@tag} #{@checkout_dir}"
   execute(mkview_cmd, options) do |io|
     puts io.read
   end
end
revisions(from_identifier, options={}) click to toggle source
# File lib/rscm/scm/clearcase.rb, line 27
def revisions(from_identifier, options={})
  options = {
    :from_identifier => from_identifier,
    :to_identifier => Time.infinity, 
    :relative_path => nil
  }.merge(options)

  checkout unless checked_out?
  rules = load_rules
  vob = vob(rules[0])
  result = Revisions.new
  
  unless vob
    STDERR.puts "No vob found. Please set load rules in the view: #{checkout_dir}"
    return result 
  end
  with_working_dir(checkout_dir) do
    since = (from_identifier + 1).strftime(TIME_FORMAT)
    cmd = "cleartool lshistory -recurse -nco -since #{since} -fmt \"#{LOG_FORMAT}\" -pname #{vob}"
    execute(cmd, options) do |io|
      # escape all quotes, except the one at the beginning and end. this is a bit ugly...
      raw_yaml = io.read
      fixed_yaml = raw_yaml.gsub(/^  message: \"/, "  message: #{MAGIC_TOKEN}")
      fixed_yaml = fixed_yaml.gsub(/\"\n\n/, "#{MAGIC_TOKEN}\n\n")
      fixed_yaml = fixed_yaml.gsub(/\"/, "\\\"")
      fixed_yaml = fixed_yaml.gsub(MAGIC_TOKEN, "\"")
 
      files = YAML.load(fixed_yaml)
      files.each do |file|
        file.path.gsub!(/\\/, "/")
        file.status = STATUSES[file.status]
        rev = revision(file.native_revision_identifier)
        if(rev && matches_load_rules?(rules, file.path))
          file.native_revision_identifier = rev
          file.previous_native_revision_identifier = revision(file.previous_native_revision_identifier)
          t = file.time
          # the time now has escaped quotes..
          file.time = Time.utc(t[2..5],t[6..7],t[8..9],t[11..12],t[13..14],t[15..16])
          file.message.strip!
          result.add(file)
        end
      end
    end
  end
  result
end
update_load_rules!(options={}) click to toggle source
# File lib/rscm/scm/clearcase.rb, line 100
def update_load_rules!(options={})
  Dir.chdir(checkout_dir) do
    # tempfile is broken on windows (!!)
    cfg_spec_file = "__rscm.cfgspec"
    config_spec_file = File.open(cfg_spec_file, "w") do |io|
      io.write(@config_spec)
    end

    setcs_cmd = "cleartool setcs #{cfg_spec_file}"
    Better.popen(setcs_cmd, "w") do |io|
      io.write "yes\n"
    end
  end
end
vob(load_rule) click to toggle source
# File lib/rscm/scm/clearcase.rb, line 124
def vob(load_rule)
  if(load_rule =~ /[\\\/]*([\w]*)/)
    $1
  else
    nil
  end
end

Protected Instance Methods

checkout_silent(to_identifier, options={}, &proc) click to toggle source
# File lib/rscm/scm/clearcase.rb, line 147
def checkout_silent(to_identifier, options={}, &proc)
  if(checked_out?)
    execute("cleartool update .", options)
  else
    mkview!
 
    # Set load rules (by setting config spec)
    #update_load_rules!
  end
end
ignore_paths() click to toggle source

Administrative files that should be ignored when counting files.

# File lib/rscm/scm/clearcase.rb, line 159
def ignore_paths
  return [/.*\.updt/]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.