Class: RSCM::CvsLogParser
Constant Summary
collapse
- REVISION_SEPARATOR =
/^----------------------------$/
- ENTRY_SEPARATOR =
/^=============================================================================$/
- STATES =
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)
{"dead" => RevisionFile::DELETED, "Exp" => RevisionFile::MODIFIED}
Instance Attribute Summary collapse
#io
Instance Method Summary
collapse
#convert_all_slashes_to_forward_slashes, #error, #had_error?, #read_until_matching_line
Constructor Details
Returns a new instance of CvsLogParser.
15
16
17
18
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 15
def initialize(io)
super(io)
@log = ""
end
|
Instance Attribute Details
#cvsmodule ⇒ Object
Returns the value of attribute cvsmodule.
13
14
15
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 13
def cvsmodule
@cvsmodule
end
|
Returns the value of attribute cvspath.
12
13
14
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 12
def cvspath
@cvspath
end
|
Instance Method Details
#determine_previous_native_revision_identifier(revision) ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 117
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
|
144
145
146
147
148
149
150
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 144
def (string, regexp)
if string=~regexp
return($1)
else
""
end
end
|
136
137
138
139
140
141
142
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 136
def (string, regexp)
if string=~regexp
return($1)
else
$stderr.puts("can't parse: '#{string}'\nexpected to match regexp: #{regexp.to_s}")
end
end
|
#make_relative_to_module(file) ⇒ Object
79
80
81
82
83
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 79
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
|
#next_log_entry ⇒ Object
35
36
37
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 35
def next_log_entry
read_until_matching_line(ENTRY_SEPARATOR)
end
|
#parse_cvs_time(time) ⇒ Object
131
132
133
134
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 131
def parse_cvs_time(time)
Time.utc(time[0..3], time[5..6], time[8..9], time[11..12], time[14..15], time[17..18])
end
|
#parse_file(file_entry) ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 85
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 = (file_entry_lines[0], /revision (.*)$/)
file.previous_native_revision_identifier = determine_previous_native_revision_identifier(file.native_revision_identifier)
file.time = parse_cvs_time((file_entry_lines[1], /date: (.*?)(;|$)/))
file.developer = (file_entry_lines[1], /author: (.*?);/)
state = (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")
if(file.message == "Initial revision" && branches == "1.1.1")
return nil
end
file
end
|
#parse_files(log_entry, revisions) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 51
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$/
revision = revisions.add(file)
end
nil
end
|
#parse_head_revision(first_entry) ⇒ Object
69
70
71
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 69
def parse_head_revision(first_entry)
head_revision = (first_entry, /^head: (.*?)$/m)
end
|
#parse_path(first_entry) ⇒ Object
73
74
75
76
77
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 73
def parse_path(first_entry)
working_file = (first_entry, /^Working file: (.*?)$/m)
return convert_all_slashes_to_forward_slashes(working_file) unless working_file.nil? || working_file == ""
make_relative_to_module((first_entry, /^RCS file: (.*?)(,v|$)/m))
end
|
#parse_revisions ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 20
def parse_revisions
revisions = Revisions.new
while(log_entry = next_log_entry)
@log<<log_entry
@log<<""
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!
end
|
#split_entries(log_entry) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/rscm/scm/cvs_log_parser.rb', line 39
def split_entries(log_entry)
entries = [""]
log_entry.each_line do |line|
if line=~REVISION_SEPARATOR
entries << ""
else
entries[entries.length-1] << line
end
end
entries
end
|