From 6b526c6aededda450597abe1c65fb249ba6801aa Mon Sep 17 00:00:00 2001 From: matitaweb Date: Fri, 7 Oct 2011 13:05:04 +0000 Subject: [PATCH] Matitaweb: fixed bugs in commit. --- matitaB/matita/matitaFilesystem.ml | 13 ++++++--- matitaB/matita/matitadaemon.ml | 42 ++++++++++++++++-------------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/matitaB/matita/matitaFilesystem.ml b/matitaB/matita/matitaFilesystem.ml index c522d1171..7ad9287df 100644 --- a/matitaB/matita/matitaFilesystem.ml +++ b/matitaB/matita/matitaFilesystem.ml @@ -75,10 +75,17 @@ let string_of_matita_flag = function 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) @@ -122,7 +129,7 @@ let stat_user user = 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 diff --git a/matitaB/matita/matitadaemon.ml b/matitaB/matita/matitadaemon.ml index 22debcda4..606ccea4a 100644 --- a/matitaB/matita/matitadaemon.ml +++ b/matitaB/matita/matitadaemon.ml @@ -85,36 +85,39 @@ let do_global_commit () = (* 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) @@ -487,16 +490,17 @@ let save (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) = 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 "ok" with | File_already_exists -> -- 2.39.2