let read_revisions file =
let s = input_file_as_string file in
let l = Str.split (Str.regexp "^----------------------------\n") s in
match l with
[] | [_] -> []
| _ :: lrev ->
let f str_rev =
let lines = Str.split (Str.regexp "\n") str_rev in
match lines with
l_number :: l_info :: l_coms ->
let number =
try
let n = String.index l_number ' ' in
let s = String.sub l_number (n+1) ((String.length l_number) - n - 1) in
List.map int_of_string (Str.split (Str.regexp "\\.") s)
with
Not_found -> []
| Invalid_argument s ->
prerr_endline s;
prerr_endline l_number ;
[]
in
let n = String.index l_info ' ' in
let n2 = String.index_from l_info n ';' in
let n3 = String.index_from l_info n2 ':' in
let n4 = String.index_from l_info n3 ';' in
let date = String.sub l_info (n + 1) (n2 - n - 1) in
let author = String.sub l_info (n3 + 1) (n4 - n3 - 1) in
let list_lines_coms =
match l_coms with
first_line :: q ->
if Str.string_match (Str.regexp "^branches:") first_line 0 then
q
else
l_coms
| _ -> l_coms
in
{
rev_number = number ;
rev_author = author ;
rev_date = date ;
rev_comment =
String.concat "\n"
(List.filter
(fun s ->
s <> ("==================================="^
"==========================================")
)
list_lines_coms
)
}
| _ ->
raise (Ocvs_types.CvsFailure (Ocvs_messages.error_analyze_revision str_rev))
in
List.map f lrev