module M = Merge_queue open Command (* A push under the run lock, as a land works under it: the read of the local branches and the record of what the remote took are one act among this machine's writers. *) module Run = M.Run.Make (M.Push) module Run_loop = Loop.Make (Run) (Perform_run.Make (M.Push) (Perform_push)) let run ctx ~remote branches = with_queue ~writes:true ctx (fun q -> initialised q @@ fun (rules, _) -> Eio.Switch.run @@ fun sw -> let now = Clock.now q.perform.clock in let run = run_name q.perform.caller ~now in let p = { q.perform with sw; run = Some run } in let context = { M.Push.rules; rules_branch = p.local.rules; default_remote = Repo.default_remote p.repo; } in let machine, actions = Run.v ~run ~mode:M.Note.Self ~wait_wall:(M.Duration.of_seconds rules.M.Rules.bounds.wait_wall) ~now (M.Push.v context { remote; branches }) in let machine = Run_loop.run ~records:(Journal.batch p.journal) ~clock:p.clock p machine actions in match Run.ending machine with | Some e -> e | None -> raise (Defect "mq push ended with no outcome"))