···6868 ; cmd =
6969 Fun
7070 (fun _ ->
7171- let curr_msg, prev_msg = get_messages () in
7272- let new_msg = prev_msg ^ curr_msg in
7371 let rev = Vars.get_selected_rev () in
7272+ let source_msg, dest_msg = get_messages rev (rev ^ "-") in
7373+ let new_msg =
7474+ [ dest_msg;source_msg ] |> String.concat_non_empty "\n"
7575+ in
7476 jj [ "squash"; "--quiet"; "-r"; rev; "-m"; new_msg ] |> ignore)
7577 }
7678 ; {
···7981 ; cmd =
8082 PromptThen
8183 ( "target revision"
8282- , fun str ->
8383- let curr_msg, prev_msg = get_messages () in
8484- let new_msg = prev_msg ^ curr_msg in
8484+ , fun target ->
8585 Dynamic_r
8686 (fun rev ->
8787+ let src_msg, dest_msg = get_messages rev target in
8888+ let new_msg =
8989+ [ dest_msg;src_msg ] |> String.concat_non_empty "\n"
9090+ in
8791 Cmd
8892 [
8993 "squash"
···9397 ; "--from"
9498 ; rev
9599 ; "--into"
9696- ; str
100100+ ; target
97101 ]) )
98102 }
99103 ; {
+10-6
jj_tui/bin/jj_process.ml
···110110 ;;
111111112112 (**gets the description of the current and previous change. Useful when squashing*)
113113- let get_messages () =
113113+ let get_messages source dest =
114114 let open Base.Result in
115115 let output =
116116 jj
···118118 "log"
119119 ; "--no-graph"
120120 ; "-T"
121121- ; {|"::"++current_working_copy++"::\n"++description++"\n::end::\n"|}
121121+ ; Printf.sprintf
122122+ {|if(self.contained_in("%s")||self.contained_in("%s"),description++"%s")++if(self.contained_in("%s")||self.contained_in("%s"),description)|}
123123+ source
124124+ source
125125+ "\u{ab}"
126126+ dest
127127+ dest
122128 ]
123129 |> String.trim
124130 in
125125- let current, prev =
126126- output |> Jj_tui.OutputParsing.parse_descriptions |> Result.get_ok
127127- in
128128- current |> String.concat "", prev |> String.concat ""
131131+ let source, dest = output |> Base.String.lsplit2_exn ~on:'\xab' in
132132+ Base.String.drop_suffix source 1, dest
129133 ;;
130134131135 open Vars
+10
jj_tui/lib/util.ml
···2929;;
30303131Base.List.intersperse
3232+3233let ( <-$ ) f v = Lwd.map ~f (Lwd.get v)
3334let ( $-> ) v f = Lwd.map ~f (Lwd.get v)
3435let ( let$$ ) v f = Lwd.map ~f (Lwd.get v)
···3637let ( >> ) f g x = g (f x)
3738let ( << ) f g x = f (g x)
3839let ( |>$$ ) v2 v f = Lwd.map2 ~f v v2
4040+4141+module String = struct
4242+ include String
4343+4444+(** Concatenates any non-empty strings in the given array*)
4545+ let concat_non_empty sep strings =
4646+ strings |> List.filter (Base.String.is_empty >> not) |> String.concat sep
4747+ ;;
4848+end