Class: RSCM::ClearCase
Constant Summary collapse
- LOG_FORMAT =
"- !ruby/object:RSCM::RevisionFile\\n developer: %u\\n time: \\\"%Nd\\\"\\n native_revision_identifier: %Vn\\n previous_native_revision_identifier: %PVn\\n path: %En\\n status: %o\\n message: \\\"%Nc\\\"\\n\\n"
- TIME_FORMAT =
"%d-%b-%Y.%H:%M:%S"
- MAGIC_TOKEN =
"9q8w7e6r5t4y"
- STATUSES =
{ "checkin" => RevisionFile::MODIFIED, "mkelem" => RevisionFile::ADDED, "rmelem" => RevisionFile::DELETED, }
- DEFAULT_CONFIG_SPEC =
"element * CHECKEDOUT\nelement * /main/LATEST"
Constants inherited from Base
Base::DEFAULT_QUIET_PERIOD, Base::THIRTY_TWO_WEEKS_AGO, Base::TWO_WEEKS_AGO
Instance Attribute Summary collapse
-
#config_spec ⇒ Object
Returns the value of attribute config_spec.
-
#stgloc ⇒ Object
Returns the value of attribute stgloc.
-
#stream ⇒ Object
Returns the value of attribute stream.
-
#tag ⇒ Object
Returns the value of attribute tag.
Attributes inherited from Base
Instance Method Summary collapse
- #catcs(options = {}) ⇒ Object
- #checked_out? ⇒ Boolean
- #destroy_working_copy(options = {}) ⇒ Object
- #import_central(options = {}) ⇒ Object
-
#initialize(stream = nil, stgloc = nil, tag = nil, config_spec = DEFAULT_CONFIG_SPEC) ⇒ ClearCase
constructor
A new instance of ClearCase.
-
#load_rules ⇒ Object
What’s loaded into view.
-
#mkview!(options = {}) ⇒ Object
Non-RSCM API methods.
- #revisions(from_identifier, options = {}) ⇒ Object
- #update_load_rules!(options = {}) ⇒ Object
- #vob(load_rule) ⇒ Object
Methods inherited from Base
#==, #add, #can_create_central?, #central_exists?, #checkout, #checkout_commandline, #checkout_dir, #checkout_dir=, #commit, #create_central, #destroy_central, #diff, #edit, #file, #install_trigger, #move, #open, #poll_new_revisions, #rootdir, #supports_trigger?, #to_identifier, #to_yaml_properties, #transactional?, #trigger_installed?, #trigger_mechanism, #uninstall_trigger, #update_commandline, #uptodate?
Constructor Details
#initialize(stream = nil, stgloc = nil, tag = nil, config_spec = DEFAULT_CONFIG_SPEC) ⇒ ClearCase
Returns a new instance of ClearCase.
21 22 23 |
# File 'lib/rscm/scm/clearcase.rb', line 21 def initialize(stream=nil, stgloc=nil, tag=nil, config_spec=DEFAULT_CONFIG_SPEC) @stream, @stgloc, @tag, @config_spec = stream, stgloc, tag, config_spec end |
Instance Attribute Details
#config_spec ⇒ Object
Returns the value of attribute config_spec.
19 20 21 |
# File 'lib/rscm/scm/clearcase.rb', line 19 def config_spec @config_spec end |
#stgloc ⇒ Object
Returns the value of attribute stgloc.
19 20 21 |
# File 'lib/rscm/scm/clearcase.rb', line 19 def stgloc @stgloc end |
#stream ⇒ Object
Returns the value of attribute stream.
19 20 21 |
# File 'lib/rscm/scm/clearcase.rb', line 19 def stream @stream end |
#tag ⇒ Object
Returns the value of attribute tag.
19 20 21 |
# File 'lib/rscm/scm/clearcase.rb', line 19 def tag @tag end |
Instance Method Details
#catcs(options = {}) ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/rscm/scm/clearcase.rb', line 113 def catcs(={}) Dir.chdir(checkout_dir) do catcs_cmd = "cleartool catcs" execute(catcs_cmd, ) do |io| yield io end end end |
#checked_out? ⇒ Boolean
72 73 74 |
# File 'lib/rscm/scm/clearcase.rb', line 72 def checked_out? !Dir["#{checkout_dir}/*"].empty? end |
#destroy_working_copy(options = {}) ⇒ Object
76 77 78 79 80 |
# File 'lib/rscm/scm/clearcase.rb', line 76 def destroy_working_copy(={}) execute("cleartool rmview #{checkout_dir}", ) do |io| io.read end end |
#import_central(options = {}) ⇒ Object
82 83 84 85 86 |
# File 'lib/rscm/scm/clearcase.rb', line 82 def import_central(={}) execute("clearfsimport -recurse -nsetevent #{[:dir]} #{checkout_dir}", ) do |io| io.read end end |
#load_rules ⇒ Object
What’s loaded into view
131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/rscm/scm/clearcase.rb', line 131 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 = {}) ⇒ Object
Non-RSCM API methods
90 91 92 93 94 95 96 |
# File 'lib/rscm/scm/clearcase.rb', line 90 def mkview!(={}) # Create view (working copy) mkview_cmd = "cleartool mkview -snapshot -stream #{@stream} -stgloc #{@stgloc} -tag #{@tag} #{@checkout_dir}" execute(mkview_cmd, ) do |io| puts io.read end end |
#revisions(from_identifier, options = {}) ⇒ Object
25 26 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 |
# File 'lib/rscm/scm/clearcase.rb', line 25 def revisions(from_identifier, ={}) = { :from_identifier => from_identifier, :to_identifier => Time.infinity, :relative_path => nil }.merge() 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, ) 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..strip! result.add(file) end end end end result end |
#update_load_rules!(options = {}) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/rscm/scm/clearcase.rb', line 98 def update_load_rules!(={}) 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) ⇒ Object
122 123 124 125 126 127 128 |
# File 'lib/rscm/scm/clearcase.rb', line 122 def vob(load_rule) if(load_rule =~ /[\\\/]*([\w]*)/) $1 else nil end end |