Method: RSCM::ClearCase#revisions

Defined in:
lib/rscm/scm/clearcase.rb

#revisions(from_identifier, options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# 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