exception SvnAnomaly of string
-let stat_classify line =
+let stat_classify line uid =
+ let basedir = (Helm_registry.get "matita.rt_base_dir") ^ "/users/" ^ uid ^ "/" in
let rec aux n acc =
match (line.[n], n) with
- | _, n when n = 7 -> String.sub line 8 ((String.length line) - 8), acc
+ | _, n when n = 7 ->
+ let fn = String.sub line 8 ((String.length line) - 8) in
+ let prefix_len = String.length basedir in
+ let fn_len = String.length fn in
+ if String.sub fn 0 prefix_len = basedir
+ then String.sub fn prefix_len (fn_len - prefix_len), acc
+ else fn, acc
| ' ', _ -> aux (n+1) acc
| 'A',0 -> aux (n+1) (Add::acc)
| 'C',_ when n = 0 || n = 1 -> aux (n+1) (Conflict::acc)
let files, anomalies =
List.fold_left (fun (facc,eacc) line ->
try
- (stat_classify line::facc), eacc
+ (stat_classify line user::facc), eacc
with
| SvnAnomaly l -> facc, l::eacc) ([],[]) outlines
in
(* call stat to get the final status *)
let files, anomalies = MatitaFilesystem.stat_user u in
- let add_count,not_added = List.fold_left
- (fun (ac_acc, na_acc) fname ->
+ let added,not_added = List.fold_left
+ (fun (a_acc, na_acc) fname ->
if List.mem fname (List.map fst files) then
- ac_acc, fname::na_acc
+ a_acc, fname::na_acc
else
- ac_acc+1, na_acc)
- (0,[]) to_be_added
+ fname::a_acc, na_acc)
+ ([],[]) to_be_added
in
- let commit_count,not_committed = List.fold_left
- (fun (cc_acc, nc_acc) fname ->
+ let committed,not_committed = List.fold_left
+ (fun (c_acc, nc_acc) fname ->
if List.mem fname (List.map fst files) then
- cc_acc, fname::nc_acc
+ c_acc, fname::nc_acc
else
- cc_acc+1, nc_acc)
- (0,[]) modified
+ fname::c_acc, nc_acc)
+ ([],[]) modified
in
let conflicts = List.map fst (List.filter
(fun (_,f) -> f = Some MatitaFilesystem.MConflict) files)
in
+ MatitaAuthentication.set_file_flag u
+ (List.map (fun x -> x, Some MatitaFilesystem.MSynchronized) (added@committed));
MatitaAuthentication.set_file_flag u files;
out ^ "\n\n" ^ (Printf.sprintf
("COMMIT RESULTS for %s\n" ^^
"==============\n" ^^
- "added and committed: %d of %d\n" ^^
- "modified and committed: %d of %d\n" ^^
+ "added and committed (%d of %d): %s\n" ^^
+ "modified and committed (%d of %d): %s\n" ^^
"not added: %s\n" ^^
"not committed: %s\n" ^^
"conflicts: %s\n")
- u add_count (List.length to_be_added) commit_count
- (List.length modified) (String.concat ", " not_added)
+ u (List.length added) (List.length to_be_added) (String.concat ", " added)
+ (List.length committed) (List.length modified) (String.concat ", " committed)
+ (String.concat ", " not_added)
(String.concat ", " not_committed) (String.concat ", " conflicts)))
"" (List.rev !to_be_committed)
List.assoc rel_filename (MatitaAuthentication.read_ft uid)
with Not_found -> MatitaFilesystem.MUnversioned
in
- if old_flag <> MatitaFilesystem.MConflict then
+ (if old_flag <> MatitaFilesystem.MConflict &&
+ old_flag <> MatitaFilesystem.MAdd then
let newflag =
if already_exists then MatitaFilesystem.MModified
else MatitaFilesystem.MAdd
in
- MatitaAuthentication.set_file_flag uid [rel_filename, Some newflag];
+ MatitaAuthentication.set_file_flag uid [rel_filename, Some newflag]);
cgi # set_header
- ~cache:`No_cache
- ~content_type:"text/xml; charset=\"utf-8\""
- ();
+ ~cache:`No_cache
+ ~content_type:"text/xml; charset=\"utf-8\""
+ ();
cgi#out_channel#output_string "<response>ok</response>"
with
| File_already_exists ->