Some cosmetic changes.
| _ -> raise (SvnAnomaly line)
in aux 0 []
+let count p l =
+ List.length (List.filter p l)
+
let stat_user user =
let rt_dir = Helm_registry.get "matita.rt_base_dir" in
let repo = Helm_registry.get "matita.weblib" in
let repo = Helm_registry.get "matita.weblib" in
let errno, outlines, errlines = exec_process
- ("svn co " ^ repo ^ " " ^ rt_dir ^ "/users/" ^ user ^ "/")
+ ("svn co --non-interactive " ^ repo ^ " " ^ rt_dir ^ "/users/" ^ user ^ "/")
in
let files, anomalies =
List.fold_left (fun (facc,eacc) line ->
let repo = Helm_registry.get "matita.weblib" in
let errno, outlines, errlines = exec_process
- ("svn up " ^ rt_dir ^ "/users/" ^ user ^ "/ --non-interactive")
+ ("svn up --non-interactive " ^ rt_dir ^ "/users/" ^ user ^ "/")
in
let files, anomalies =
List.fold_left (fun (facc,eacc) line ->
try
(let fname,flags = up_classify line user in
- (fname,matita_flag_of_update flags)::facc), eacc
+ (fname, flags)::facc), eacc
with
| SvnAnomaly l -> facc, l::eacc) ([],[]) outlines
in
- if errno = 0 then files, anomalies
+ let added = count (fun (_,flags) -> List.mem Add flags) files in
+ let conflict = count (fun (_,flags) -> List.mem Conflict flags) files in
+ let del = count (fun (_,flags) -> List.mem Delete flags) files in
+ let upd = count (fun (_,flags) -> List.mem Update flags) files in
+ let merged = count (fun (_,flags) -> List.mem Merge flags) files in
+
+ let files =
+ List.map (fun (fname,flags) -> fname,matita_flag_of_update flags) files
+ in
+
+ if errno = 0 then files, anomalies, (added,conflict,del,upd,merged)
else raise (SvnError (string_of_output outlines errlines))
;;
let repo = Helm_registry.get "matita.weblib" in
let errno, outlines, errlines = exec_process
- ("svn ci --message \"commit by user " ^ user ^ "\" " ^ rt_dir ^ "/users/" ^ user ^ "/")
+ ("svn ci --non-interactive --message \"commit by user " ^ user ^ "\" " ^ rt_dir ^ "/users/" ^ user ^ "/")
in
- if errno = 0 then ()
+ if errno = 0 then
+ "BEGIN COMMIT - " ^ user ^ ":\n" ^ (string_of_output outlines errlines) ^ "END COMMIT - " ^ user ^ "\n\n"
else raise (SvnError (string_of_output outlines errlines))
;;
let do_global_commit () =
prerr_endline ("to be committed: " ^ String.concat " " !to_be_committed);
List.fold_left
- (fun acc u ->
+ (fun (acc,out) u ->
try
- commit u;
- acc
+ let newout = commit u in
+ acc, out ^ newout
with
| SvnError outstr ->
- prerr_endline outstr;
- u::acc)
- [] (List.rev !to_be_committed)
+ prerr_endline ("COMMIT OF " ^ user ^ "FAILED:" ^ outstr);
+ u::acc,out)
+ ([],"") (List.rev !to_be_committed)
;;
val add_user : string -> unit
-val do_global_commit : unit -> string list
+val do_global_commit : unit -> string list * string
-val update_user : string -> (string * matita_flag option) list * string list
+val update_user :
+ string ->
+ (string * matita_flag option) list * string list * (int*int*int*int*int)
val stat_user : string -> (string * svn_flag list) list * string list
(* prerr_endline ("sending metasenv:\n" ^ res); res *)
;;
-(* let html_of_status s =
- let _,_,metasenv,subst,_ = s#obj in
- let txt = List.fold_left
- (fun acc (nmeta,_ as meta) ->
- let txt0 = snd (ApplyTransformation.ntxt_of_cic_sequent
- ~metasenv ~subst ~map_unicode_to_tex:false 80 s meta)
- in
- prerr_endline ("### txt0 = " ^ txt0);
- ("<B>Goal ?" ^ (string_of_int nmeta) ^ "</B>\n" ^ txt0)::acc)
- [] metasenv
- in
- String.concat "\n\n" txt
-;; *)
-
let html_of_matita s =
let patt1 = Str.regexp "\005" in
let patt2 = Str.regexp "\006" in
let cgi = Netcgi1_compat.Netcgi_types.of_compat_activation cgi in
let env = cgi#environment in
(try
- let errors = MatitaFilesystem.do_global_commit () in
- prerr_endline ("commit errors: " ^ (String.concat " " errors));
+ let errors,out = MatitaFilesystem.do_global_commit () in
cgi # set_header
~cache:`No_cache
~content_type:"text/xml; charset=\"utf-8\""
();
- cgi#out_channel#output_string "<response>ok</response>"
+ cgi#out_channel#output_string "<commit>";
+ cgi#out_channel#output_string "<response>ok</response>";
+ cgi#out_channel#output_string "<details>" ^ out ^ "</details>";
+ cgi#out_channel#output_string "</commit>"
with
| Not_found _ ->
cgi # set_header
let sid = HExtlib.unopt sid in
let uid = MatitaAuthentication.user_of_session sid in
(try
- let files,anomalies = MatitaFilesystem.update_user uid in
- (* let changed = HExtlib.filter_map
- (fun (fl,n) -> if (List.mem MatitaFilesystem.Modified fl) then Some n else None) files
- in
- let changed = String.concat "\n" changed in
- let anomalies = String.concat "\n" anomalies in
- prerr_endline ("Changed:\n" ^ changed ^ "\n\nAnomalies:\n" ^ anomalies); *)
+ let files,anomalies,(added,conflict,del,upd,merged) =
+ MatitaFilesystem.update_user uid
+ in
+ let anomalies = String.concat "\n" anomalies in
+ let details = Printf.sprintf
+ ("%d new files\n"^^
+ "%d deleted files\n"^^
+ "%d updated files\n"^^
+ "%d merged files\n"^^
+ "%d conflicting files\n\n" ^^
+ "Anomalies:\n%s") added del upd merged conflict anomalies
+ in
+ prerr_endline ("update details:\n" ^ details);
+ let details =
+ Netencoding.Html.encode ~in_enc:`Enc_utf8 ~prefer_name:false () details
+ in
MatitaAuthentication.set_file_flag uid files;
cgi # set_header
~cache:`No_cache
~content_type:"text/xml; charset=\"utf-8\""
();
- cgi#out_channel#output_string "<response>ok</response>"
+ cgi#out_channel#output_string "<update>";
+ cgi#out_channel#output_string "<response>ok</response>";
+ cgi#out_channel#output_string ("<details>" ^ details ^ "</details>");
+ cgi#out_channel#output_string "</update>";
with
| Not_found _ ->
cgi # set_header
var patt3 = />/gi
var patt4 = /</gi;
var patt5 = />/gi;
+ var patt6 = / /gi;
var result = this;
result = result.replace(patt1,"\n");
result = result.replace(patt2,"\005");
result = result.replace(patt3,"\006");
result = result.replace(patt4,"<");
result = result.replace(patt5,">");
+ result = result.replace(patt6," ");
return (unescape(result));
}
// debug(xml.getElementsByTagName("file")[0].childNodes[0].nodeValue);
// unlocked.innerHTML = xml.getElementsByTagName("file")[0].childNodes[0].nodeValue;
debug(xml.childNodes[0].textContent);
- unlocked.innerHTML = xml.childNodes[0].textContent;
+ if (document.all) { // IE
+ unlocked.innerHTML = xml.childNodes[0].text;
+ } else {
+ unlocked.innerHTML = xml.childNodes[0].textContent;
+ }
} else {
debug("file open failed");
{
processor = function(xml) {
if (is_defined(xml)) {
- debug("commit succeeded(?)");
+ debug(xml.getElementsByTagName("details")[0].textContent);
+ alert("Commit executed: see details in the log.\n\n" +
+ "NOTICE: this message does NOT imply (yet) that the commit was successful.");
} else {
- debug("commit failed!");
+ alert("Commit failed!");
}
resume();
};
{
processor = function(xml) {
if (is_defined(xml)) {
- debug("update succeeded(?)");
+ alert("Update executed.\n\n" +
+ "Details:\n" +
+ xml.getElementsByTagName("details")[0].textContent);
} else {
- debug("update failed!");
+ alert("Update failed!");
}
resume();
};