]> matita.cs.unibo.it Git - helm.git/blobdiff - matitaB/matita/matitaFilesystem.ml
Matitaweb: implementation of file-flagging for keeping track of modified files
[helm.git] / matitaB / matita / matitaFilesystem.ml
index 77e65822163657ffc7af9fce3bb662999f41148e..637a997dcd09612e4fa73f9ac638c08456ddcad1 100644 (file)
@@ -122,10 +122,17 @@ let stat_user user =
 ;;
 
 (* 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)
@@ -136,6 +143,12 @@ let up_classify line =
     | _ -> 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
@@ -147,7 +160,7 @@ let checkout user =
   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
@@ -254,12 +267,13 @@ let update_user user =
   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