X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matitaB%2Fmatita%2FmatitaFilesystem.ml;h=1ea3cbb94267204b899d0497392d36eca0ea1dff;hb=365bd84918e8e2fe0c6f3714b94e81b443a8f244;hp=c522d1171f2784a59b26ac95559a1ccfcffd7af3;hpb=21d29bf473dd0d89f555dc17e4f2b7b9b4ad6bd1;p=helm.git diff --git a/matitaB/matita/matitaFilesystem.ml b/matitaB/matita/matitaFilesystem.ml index c522d1171..1ea3cbb94 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 @@ -296,37 +303,41 @@ let update_user user = ;; let add_files user files = - let rt_dir = Helm_registry.get "matita.rt_base_dir" in - let _repo = Helm_registry.get "matita.weblib" in - - let files = String.concat " " - (List.map ((^) (rt_dir ^ "/users/" ^ user ^ "/")) files) in - - let errno, outlines, errlines = - if files <> "" then - exec_process ("svn add --non-interactive " ^ files) - else 0,[],[] - in - if errno = 0 then - "BEGIN ADD - " ^ user ^ ":\n" ^ (string_of_output outlines errlines) ^ "END ADD - " ^ user ^ "\n\n" - else raise (SvnError (string_of_output outlines errlines)) + if (List.length files > 0) then + (let rt_dir = Helm_registry.get "matita.rt_base_dir" in + let _repo = Helm_registry.get "matita.weblib" in + + let files = String.concat " " + (List.map ((^) (rt_dir ^ "/users/" ^ user ^ "/")) files) in + + let errno, outlines, errlines = + if files <> "" then + exec_process ("svn add --non-interactive " ^ files) + else 0,[],[] + in + if errno = 0 then + "BEGIN ADD - " ^ user ^ ":\n" ^ (string_of_output outlines errlines) ^ "END ADD - " ^ user ^ "\n\n" + else raise (SvnError (string_of_output outlines errlines))) + else ("ADD - nothing to do for " ^ user ^ "\n") ;; (* this function should only be called by the server itself (or * the admin) at a scheduled time, so no concurrent instances and no CS needed * also, svn should already be safe as far as concurrency is concerned *) let commit user files = - let rt_dir = Helm_registry.get "matita.rt_base_dir" in - let _repo = Helm_registry.get "matita.weblib" in - - let files = String.concat " " - (List.map ((^) (rt_dir ^ "/users/" ^ user ^ "/")) files) in - - let errno, outlines, errlines = exec_process - ("svn ci --non-interactive --message \"commit by user " ^ user ^ "\" " ^ files) - in - 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)) + if (List.length files > 0) then + (let rt_dir = Helm_registry.get "matita.rt_base_dir" in + let _repo = Helm_registry.get "matita.weblib" in + + let files = String.concat " " + (List.map ((^) (rt_dir ^ "/users/" ^ user ^ "/")) files) in + + let errno, outlines, errlines = exec_process + ("svn ci --non-interactive --message \"commit by user " ^ user ^ "\" " ^ files) + in + 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))) + else ("COMMIT nothing to do for " ^ user ^ "\n") ;;