Class RSCM::SubversionLogEntryParser
In: lib/rscm/scm/subversion_log_parser.rb
Parent: Parser

Methods

Constants

STATES = {"M" => RevisionFile::MODIFIED, "A" => RevisionFile::ADDED, "D" => RevisionFile::DELETED} unless defined? STATES

Public Class methods

[Source]

    # File lib/rscm/scm/subversion_log_parser.rb, line 49
49:     def initialize(url, path=nil)
50:       super(/^------------------------------------------------------------------------/)
51:       @url = url
52:       @path = path
53:     end

Public Instance methods

[Source]

    # File lib/rscm/scm/subversion_log_parser.rb, line 55
55:     def parse(io, skip_line_parsing=false, &line_proc)
56:       # We have to trim off the last newline - it's not meant to be part of the message

57:       revision = super
58:       revision.message = revision.message[0..-2] if revision
59:       revision
60:     end

[Source]

    # File lib/rscm/scm/subversion_log_parser.rb, line 62
62:     def relative_path(url, path_from_root)
63:       path_from_root = path_from_root.chomp
64:       url_tokens = url.split('/')
65:       path_from_root_tokens = path_from_root.split('/')
66:       
67:       max_similar = path_from_root_tokens.length
68:       while(max_similar > 0)
69:         url = url_tokens[-max_similar..-1]
70:         path = path_from_root_tokens[0..max_similar-1]
71:         if(url == path)
72:           break
73:         end
74:         max_similar -= 1
75:       end
76: 
77:       if(max_similar == 0) 
78:         if(@path.nil? || @path == "")
79:           path_from_root
80:         else
81:           nil
82:         end
83:       else
84:         path_from_root_tokens[max_similar..-1].join("/")
85:       end
86:     end

Protected Instance methods

[Source]

     # File lib/rscm/scm/subversion_log_parser.rb, line 117
117:     def next_result
118:       result = @revision
119:       @revision = nil
120:       result
121:     end

[Source]

     # File lib/rscm/scm/subversion_log_parser.rb, line 90
 90:     def parse_line(line)
 91:       if(@revision.nil?)
 92:         parse_header(line)
 93:       elsif(line.strip == "")
 94:         @parse_state = :parse_message
 95:       elsif(line =~ /Changed paths/)
 96:         @parse_state = :parse_files
 97:       elsif(@parse_state == :parse_files)
 98:         file = parse_file(line)
 99:         if(file && file.path)
100:           previously_added_file = @revision[-1]
101:           if(previously_added_file)
102:             # remove previous revision_file if it's a dir

103:             previous_tokens = previously_added_file.path.split("/")
104:             current_tokens = file.path.split("/")
105:             current_tokens.pop
106:             if(previous_tokens == current_tokens)
107:               @revision.pop
108:             end
109:           end
110:           @revision.add file
111:         end
112:       elsif(@parse_state == :parse_message)
113:         @revision.message << line.chomp << "\n"
114:       end
115:     end

[Validate]