···4646 (* From now on we use ignore-working-copy so we don't re-snapshot the state and so
4747 we can operate in paralell *)
4848 (* TODO: stop using dop last twice *)
4949- Show_view.reRender ();
4949+ Show_view.re_render ();
5050 let files_list = Flock.fork_as_promise (fun _ -> list_files ~rev ()) in
5151 Vars.ui_state.jj_branches $= branches;
5252 (*wait for all our tasks*)
+3
jj_tui/bin/graph_view.ml
···430430 (*Respond to change in selected revision*)
431431 Lwd.set Vars.ui_state.hovered_revision hovered;
432432 Lwd.set Vars.ui_state.selected_revisions selected;
433433+ (*If the files are focused we shouldn't send this*)
434434+ if Show_view.lastMessage
433435 Show_view.(pushStatus (Graph_preview (Vars.get_hovered_rev ())));
436436+434437 [%log debug "Hovered revision: '%s'" (Global_vars.get_unique_id hovered)];
435438 Picos_std_structured.Flock.fork (fun () -> Global_funcs.update_views ()))
436439 ~custom_handler:(fun ~selected ~selectable_items key -> handleKeys key)
+1-1
jj_tui/bin/show_view.ml
···1212let pushStatus status = Stream.push statusStream status
13131414(** pushes the last message to the queue again to re-render everything *)
1515-let reRender () = lastMessage |> Option.iter pushStatus
1515+let re_render () = lastMessage |> Option.iter pushStatus
16161717module Make (Vars : Global_vars.Vars) = struct
1818 open Lwd_infix
+23-20
jj_tui/lib/logging.ml
···11(** A version of the logging module that adds timestamps to the logs *)
2233+let time_to_string tm =
44+ let ms = (tm |> Float.modf |> fst) *. 1000. |> Float.to_int in
55+ let tm = tm |> Unix.localtime in
66+ Printf.sprintf
77+ "%04d-%02d-%02d %02d:%02d:%02d.%03d"
88+ (tm.Unix.tm_year + 1900)
99+ (tm.Unix.tm_mon + 1)
1010+ tm.Unix.tm_mday
1111+ tm.Unix.tm_hour
1212+ tm.Unix.tm_min
1313+ tm.Unix.tm_sec
1414+ ms
1515+;;
1616+317module Log = struct
418 let timestamp_tag =
55- let now () = Unix.gettimeofday () |> Unix.localtime in
66- let time_to_string tm =
77- Printf.sprintf
88- "%04d-%02d-%02d %02d:%02d:%02d"
99- (tm.Unix.tm_year + 1900)
1010- (tm.Unix.tm_mon + 1)
1111- tm.Unix.tm_mday
1212- tm.Unix.tm_hour
1313- tm.Unix.tm_min
1414- tm.Unix.tm_sec
1515- in
1619 Logs.Tag.def "timestamp" ~doc:"Timestamp" (fun fmt tm ->
1720 time_to_string tm |> Format.pp_print_string fmt)
1821 ;;
···2023 let timestamp_wrap fn : ('a, 'b) Logs.msgf =
2124 fun m ->
2225 fn (fun ?header ?(tags = Logs.Tag.empty) fmt ->
2323- let timestamp = Unix.gettimeofday () |> Unix.localtime in
2424- let tags = Logs.Tag.add timestamp_tag timestamp Logs.Tag.empty in
2626+ let timestamp = Unix.gettimeofday () in
2727+ let tags = Logs.Tag.add timestamp_tag timestamp tags in
2528 m ?header ~tags fmt)
2629 ;;
2730···64676568 (** Removes old log files, keeping only the 20 most recent *)
6669 let cleanup_logs log_path =
7070+ [%log debug "cleaning up logs at %s" log_path];
6771 let log_files =
6872 Sys.readdir log_path
6973 |> Array.to_list
···7781 if i >= 20
7882 then (
7983 let file_path = Filename.concat log_path file in
8080- Unix.unlink file_path))
8484+ Unix.unlink file_path;
8585+ [%log debug "deleted log file:%s" file_path]))
8186 log_files
8287 ;;
8388···140145 (*just no logging if we can't find a log file*)
141146 (*TODO: log to stderr *)
142147 match get_log_dir () with
143143- | Some log_dir ->
148148+ | Some state_dir ->
149149+ let log_dir = Filename.concat state_dir "jj_tui" in
144150 (*creates or opens the log file*)
145151 let get_log_file_channel () =
146146- let jj_tui_dir = Filename.concat log_dir "jj_tui" in
147147- (try Unix.mkdir jj_tui_dir 0o755 with
148148- | Unix.Unix_error (Unix.EEXIST, _, _) ->
149149- ());
152152+ (try Unix.mkdir log_dir 0o755 with Unix.Unix_error (Unix.EEXIST, _, _) -> ());
150153 let timestamp = Unix.time () |> Unix.localtime in
151154 let timestamp_str =
152155 Printf.sprintf
···159162 timestamp.tm_sec
160163 in
161164 let log_file =
162162- Filename.concat jj_tui_dir (Printf.sprintf "log_%s.log" timestamp_str)
165165+ Filename.concat log_dir (Printf.sprintf "log_%s.log" timestamp_str)
163166 in
164167 let log_channel = open_out_gen [ Open_append; Open_creat ] 0o644 log_file in
165168 log_channel