Class: RSCM::MonotoneLogParser
- Inherits:
-
Object
- Object
- RSCM::MonotoneLogParser
- Defined in:
- lib/rscm/scm/monotone_log_parser.rb
Instance Method Summary collapse
- #parse_revision(revision_io, path_revisions) ⇒ Object
- #parse_revisions(io, from_identifier = Time.epoch, to_identifier = Time.infinity) ⇒ Object
Instance Method Details
#parse_revision(revision_io, path_revisions) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rscm/scm/monotone_log_parser.rb', line 49 def parse_revision(revision_io, path_revisions) revision = Revision.new state = nil revision_io.each_line do |line| if(line =~ /^Revision: (.*)$/ && revision.identifier.nil?) revision.identifier = $1 elsif(line =~ /^Author: (.*)$/ && revision.developer.nil?) revision.developer = $1 elsif(line =~ /^Date: (.*)$/ && revision.time.nil?) revision.time = Time.utc( $1[0..3].to_i, $1[5..6].to_i, $1[8..9].to_i, $1[11..12].to_i, $1[14..15].to_i, $1[17..18].to_i ) elsif(line =~ /^ChangeLog:\s*$/ && revision..nil?) state = :message elsif(state == :message && revision..nil?) revision. = "" elsif(state == :message && revision.) revision. << line elsif(line =~ /^Added files:\s*$/) state = :added elsif(state == :added) add_changes(revision, line, RevisionFile::ADDED, path_revisions) elsif(line =~ /^Modified files:\s*$/) state = :modified elsif(state == :modified) add_changes(revision, line, RevisionFile::MODIFIED, path_revisions) end end revision..chomp! rescue revision. = '' revision end |
#parse_revisions(io, from_identifier = Time.epoch, to_identifier = Time.infinity) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rscm/scm/monotone_log_parser.rb', line 9 def parse_revisions(io, from_identifier=Time.epoch, to_identifier=Time.infinity) # skip first separator io.readline all_revisions = [] revision_string = "" # hash of path => [array of revisions] path_revisions = {} io.each_line do |line| if(line =~ /-----------------------------------------------------------------/) revision = parse_revision(StringIO.new(revision_string), path_revisions) all_revisions << revision revision_string = "" else revision_string << line end end revision = parse_revision(StringIO.new(revision_string), path_revisions) all_revisions << revision # Filter out the revisions and set the previous revisions, knowing that most recent is at index 0. from_time = time(all_revisions, from_identifier, Time.epoch) to_time = time(all_revisions, to_identifier, Time.infinity) revisions = Revisions.new all_revisions.each do |revision| if((from_time < revision.time) && (revision.time <= to_time)) revisions.add(revision) revision.each do |change| current_index = path_revisions[change.path].index(change.native_revision_identifier) change.previous_native_revision_identifier = path_revisions[change.path][current_index + 1] end end end revisions end |