AbstractLogParser
The state field is “Exp” both for added and modified files. retards! We need some additional logic to figure out whether it is added or not. Maybe look at the revision. (1.1 means new I think. - deal with it later)
# File lib/rscm/scm/cvs_log_parser.rb, line 115 def determine_previous_native_revision_identifier(revision) if revision =~ /(.*)\.(.*)/ big_version_number = $1 small_version_number = $2.to_i if small_version_number == 1 nil else "#{big_version_number}.#{small_version_number - 1}" end else nil end end
# File lib/rscm/scm/cvs_log_parser.rb, line 137 def extract_match(string, regexp) if string=~regexp return($1) else "" end end
# File lib/rscm/scm/cvs_log_parser.rb, line 129 def extract_required_match(string, regexp) if(string =~ regexp) return($1) else $stderr.puts("can't parse: '#{string}'\nexpected to match regexp: #{regexp.to_s}") end end
# File lib/rscm/scm/cvs_log_parser.rb, line 72 def make_relative_to_module(file) return file if cvspath.nil? || cvsmodule.nil? || file.nil? cvspath = convert_all_slashes_to_forward_slashes(self.cvspath) convert_all_slashes_to_forward_slashes(file).gsub(/^#{cvspath}\/#{cvsmodule}\//, "") end
# File lib/rscm/scm/cvs_log_parser.rb, line 33 def next_log_entry read_until_matching_line(ENTRY_SEPARATOR) end
# File lib/rscm/scm/cvs_log_parser.rb, line 78 def parse_file(file_entry) raise "can't parse: #{file_entry}" if file_entry =~ REVISION_SEPARATOR file_entry_lines = file_entry.split(/\r?\n/) file = RevisionFile.new file.native_revision_identifier = extract_match(file_entry_lines[0], /revision (.*)$/) file.previous_native_revision_identifier = determine_previous_native_revision_identifier(file.native_revision_identifier) time = extract_required_match(file_entry_lines[1], /date: (.*?)(;|$)/) if(time.strip.length == 19) # CVS 1.11.x doesn't specify timezone (but assumes UTC), so we'll add it here. time += " +0000" end file.time = Time.parse(time).utc file.developer = extract_match(file_entry_lines[1], /author: (.*?);/) state = extract_match(file_entry_lines[1], /state: (.*?);/) file.status = STATES[state] message_start = 2 branches = nil if(file_entry_lines[2] =~ /^branches:\s+(.*);/) message_start = 3 branches = $1 end file.message = file_entry_lines[message_start..-1].join("\n") # Ignore the initial revision from import - we will have two of them if(file.message == "Initial revision" && branches == "1.1.1") return nil end file end
# File lib/rscm/scm/cvs_log_parser.rb, line 49 def parse_files(log_entry, revisions) entries = split_entries(log_entry) entries[1..entries.length].each do |entry| file = parse_file(entry) next if file.nil? file.path = parse_path(entries[0]) file.status = RevisionFile::ADDED if file.native_revision_identifier =~ /1\.1$/ revisions.add(file) end nil end
# File lib/rscm/scm/cvs_log_parser.rb, line 62 def parse_head_revision(first_entry) head_revision = extract_match(first_entry, /^head: (.*?)$/) end
# File lib/rscm/scm/cvs_log_parser.rb, line 66 def parse_path(first_entry) working_file = extract_match(first_entry, /^Working file: (.*?)$/) return convert_all_slashes_to_forward_slashes(working_file) unless working_file.nil? || working_file == "" make_relative_to_module(extract_required_match(first_entry, /^RCS file: (.*?)(,v|$)/)) end
# File lib/rscm/scm/cvs_log_parser.rb, line 19 def parse_revisions revisions = Revisions.new while(log_entry = next_log_entry) begin parse_files(log_entry, revisions) rescue Exception => e $stderr.puts("could not parse log entry: #{log_entry}\ndue to: #{e.message}\n\t") $stderr.puts(e.backtrace.join("\n\t")) end end revisions.sort! revisions end
Generated with the Darkfish Rdoc Generator 2.