terminal user interface to jujutsu. Focused on speed and clarity
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

ensure nottui is using same mutex as picos

Eli Dowling ab6ccea4 a7e2ccaf

+38 -52
+7
forks/lwd/lib/lwd/lwd.mli
··· 1 + module Mutex : Mutex_backend.MUTEX 2 + (** 3 + This is the mutex we use. it can be different depending on the backend we use. 4 + For example, if we use picos, we use the picos mutex. 5 + If we use the stdlib, we use the stdlib mutex. 6 + *) 7 + 1 8 type +'a t 2 9 (** A dynamic document of type ['a]. Documents can be produced in several 3 10 different ways:
+1
forks/lwd/lib/lwd/lwd_impl.ml
··· 1 1 module Make (Mutex : Mutex_backend.MUTEX) = struct 2 + module Mutex=Mutex 2 3 let log_src = Logs.Src.create "lwd.impl" ~doc:"Lwd implementation" 3 4 module Log = (val Logs.src_log log_src : Logs.LOG) 4 5
+1
forks/lwd/lib/lwd_picos/lwd.ml
··· 1 + 1 2 include Lwd_impl.Make(Mutex_picos) 2 3 3 4 (* This should prevent the set from being cancelled and leaving hanging locks*)
+2
forks/nottui/lib/nottui/nottui_main.ml
··· 1 1 open Notty 2 2 open Lwd_utils 3 + (*Use the same mutex backend as lwd*) 4 + module Mutex=Lwd.Mutex 3 5 (* test comment *) 4 6 module Log = (val Logs.src_log (Logs.Src.create "nottui")) 5 7
+2 -2
jj_tui/bin/jj_commands.ml
··· 45 45 | SubCmd of 'a command Key_Map.t 46 46 (** Allows nesting of commands, shows a popup with command options and waits for the user to press the appropriate key*) 47 47 | Fun of (unit -> unit) 48 - (** Execute an arbitrary function. Prefer other command types if possible *) 48 + (** Just like command, except that it runs async and shows a throbber while it's running. Useful for long running commands*) 49 49 | Cmd_async of string * cmd_args 50 50 [@@deriving show] 51 51 ··· 211 211 | Cmd_async (loading_msg,args) -> 212 212 jj_async 213 213 args 214 - ~on_start:(fun () -> show_popup @@ Some (W.hbox [ Jj_widgets.throbber ;(W.string (" "^loading_msg)|>Lwd.pure) ], loading_msg)) 214 + ~on_start:(fun () -> show_popup @@ Some (W.hbox [ Jj_widgets.throbber ;(W.string (" "^loading_msg)|>Lwd.pure) ], "loading...")) 215 215 ~on_success:(fun _ -> 216 216 Global_funcs.update_status ~cause_snapshot:true (); 217 217 show_popup None)
+22 -48
jj_tui/bin/jj_process.ml
··· 196 196 code, status, stdout, stderr,pid 197 197 ;; 198 198 199 - let jj_async ?(snapshot = true) ?(color = true) args ~on_start ~on_success ~on_error = 200 - let run () = 201 - let locked = 202 - if snapshot 203 - then ( 204 - Mutex.lock access_lock; 205 - true) 206 - else false 207 - in 208 - let res = 209 - try 210 - let _, status, out, err, _ = 211 - picos_process 212 - "jj" 213 - (List.concat 214 - [ 215 - args 216 - ; [ "--no-pager" ] 217 - ; (if snapshot then [] else [ "--ignore-working-copy" ]) 218 - ; (if color then [ "--color"; "always" ] else [ "--color"; "never" ]) 219 - ]) 220 - in 221 - let exit_code = 222 - match status with 223 - | Unix.WEXITED code -> 224 - code 225 - | Unix.WSIGNALED _ | Unix.WSTOPPED _ -> 226 - -1 227 - in 228 - if exit_code = 0 then Ok (out, err) else Error (exit_code, out, err) 229 - with 230 - | exn -> 231 - if locked then Mutex.unlock access_lock; 232 - raise exn 233 - in 234 - if locked then Mutex.unlock access_lock; 235 - match res with 236 - | Ok (out, err) -> 237 - on_success (out, err) 238 - | Error (code, out, err) -> 239 - on_error code (err ^ out) 240 - in 241 - on_start (); 242 - Picos_std_structured.Flock.fork(fun _ -> 243 - run(); 244 - 245 - ); 246 - ;; 247 199 248 200 (* Ui_loop.run (Lwd.pure (W.printf "Hello world"));; *) 249 201 let cmdArgs cmd args = ··· 350 302 Vars.ui_state.command_log 351 303 (([ "jj" ] @ args |> String.concat " ") :: current_log); 352 304 jj_no_log ~snapshot args 305 + ;; 306 + 307 + (**Run a jj command asynchronously with callbacks for success, error, and start*) 308 + let jj_async ?(snapshot = true) ?(color = true) args ~on_start ~on_success ~on_error = 309 + let run () = 310 + let res = jj_no_log_errorable ~snapshot ~color args in 311 + match res with 312 + | Ok (out, err) -> 313 + on_success (out, err) 314 + | Error (`BadExit (code, msg)) -> 315 + on_error code msg 316 + | Error (`Exception msg) -> 317 + on_error (-1) msg 318 + in 319 + on_start (); 320 + Picos_std_structured.Flock.fork (fun () -> 321 + try run () 322 + with 323 + | exn -> 324 + let msg = Printexc.to_string exn in 325 + [%log warn "Exception in jj_async: %s" msg]; 326 + on_error (-1) msg) 353 327 ;; 354 328 355 329 (**gets the description of the current and previous change. Useful when squashing*)
+3 -2
jj_tui/bin/jj_widgets.ml
··· 216 216 217 217 (* let update_throb= Lwd.var 0 in *) 218 218 Lwd.bind (Lwd.get frame_var) ~f:(fun frame -> 219 + (*each time we re-render, we start a new thread to update the frame the next time*) 219 220 Picos_std_structured.Flock.fork(fun _ -> 220 - Unix.sleepf 0.2; 221 + Unix.sleepf 0.1; 221 222 Lwd.set frame_var (Lwd.peek frame_var + 1); 222 223 ); 223 - W.string ~attr:A.(fg red) (frames.(frame mod len) )|>Lwd.pure 224 + W.string ~attr:A.(fg blue) (frames.(frame mod len) )|>Lwd.pure 224 225 ) 225 226 ;; 226 227