[]
;;
-let set_file_flag uid filename flag =
- let filename = MatitaFilesystem.normalize_qfn filename in
+let set_file_flag uid files_flags =
let ft = read_ft uid in
- let oldflag =
- try List.assoc filename ft
- with Not_found -> MatitaFilesystem.MSynchronized
+ let files = List.map fst files_flags in
+ let ft = List.filter (fun (x,_) -> not (List.mem x files)) ft in
+ let ft' = List.fold_left (fun acc (filename,flag) ->
+ let filename = MatitaFilesystem.normalize_qfn filename in
+ try
+ (filename,HExtlib.unopt flag)::acc
+ with Failure _ -> acc) [] files_flags
in
- if oldflag <> MatitaFilesystem.MConflict
- then
- let ft = (filename,flag)::
- List.filter (fun (fn,_) -> fn <> filename) ft in
- write_ft uid ft
- else ()
+ write_ft uid (ft'@ft)
;;
let add_user uid pw =
;;
(* update and checkout *)
-let up_classify line =
+let up_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 = 4 -> String.sub line 5 ((String.length line) - 5), acc
+ | _, n when n = 4 ->
+ let fn = String.sub line 5 ((String.length line) - 5) 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',_ when n = 0 || n = 1 -> aux (n+1) (Add::acc)
| 'C',_ when n = 0 || n = 1 -> aux (n+1) (Conflict::acc)
| _ -> raise (SvnAnomaly line)
in aux 0 []
+let matita_flag_of_update fs =
+ if List.mem Conflict fs then Some MConflict
+ else if List.mem Delete fs then None
+ else if List.mem Merge fs then Some MModified
+ else Some MSynchronized
+
(* this should be executed only for a freshly created user so no CS is needed *)
let checkout user =
let rt_dir = Helm_registry.get "matita.rt_base_dir" in
let files, anomalies =
List.fold_left (fun (facc,eacc) line ->
try
- (up_classify line::facc), eacc
+ (up_classify line user::facc), eacc
with
| SvnAnomaly l -> facc, l::eacc) ([],[]) outlines
in
let repo = Helm_registry.get "matita.weblib" in
let errno, outlines, errlines = exec_process
- ("svn up " ^ rt_dir ^ "/users/" ^ user ^ "/")
+ ("svn up " ^ rt_dir ^ "/users/" ^ user ^ "/ --non-interactive")
in
let files, anomalies =
List.fold_left (fun (facc,eacc) line ->
try
- (up_classify line::facc), eacc
+ (let fname,flags = up_classify line user in
+ (fname,matita_flag_of_update flags)::facc), eacc
with
| SvnAnomaly l -> facc, l::eacc) ([],[]) outlines
in
(* prerr_endline ("done."); *)
end;
end;
- MatitaAuthentication.set_file_flag uid rel_filename MatitaFilesystem.MModified;
+ MatitaAuthentication.set_file_flag uid
+ [rel_filename, Some MatitaFilesystem.MModified];
cgi # set_header
~cache:`No_cache
~content_type:"text/xml; charset=\"utf-8\""
let changed = String.concat "\n" changed in
let anomalies = String.concat "\n" anomalies in
prerr_endline ("Changed:\n" ^ changed ^ "\n\nAnomalies:\n" ^ anomalies); *)
+ MatitaAuthentication.set_file_flag uid files;
cgi # set_header
~cache:`No_cache
~content_type:"text/xml; charset=\"utf-8\""