···1212 module Process = Jj_process.Make (Vars)
1313 open Process
1414 open Jj_tui.Process_wrappers.Make (Process)
1515-1515+1616 (* Import graph commands *)
1717 module GraphCommands = Graph_commands.Make (Vars)
1818-1818+1919 let bookmark_select_prompt get_bookmark_list name func =
2020 Selection_prompt
2121 ( name
···33333434 (* Remove the hardcoded make_command_mapping function and use the dynamic one *)
3535 let command_mapping = ref None
3636-3636+3737 let rec get_command_mapping () =
3838 match !command_mapping with
3939- | Some mapping -> mapping
3939+ | Some mapping ->
4040+ mapping
4041 | None ->
4142 let key_map = (Lwd.peek ui_state.config).key_map.graph in
4243 let registry = GraphCommands.get_command_registry get_command_mapping in
···6465 |> Lwd.get
6566 |> Lwd.map2 (Lwd.get Vars.ui_state.revset) ~f:(fun revset _ ->
6667 try
6767- let res = graph_and_revs ?revset () in
6868+ let max_commits = (Vars.config |> Lwd.peek).max_commits in
6969+ let res = graph_and_revs ?revset max_commits () in
6870 error_var $= None;
6971 res
7072 with
+9-12
jj_tui/lib/config.ml
···11open Util
22open Logging
3344+type t = {
55+ key_map : Key_map.key_config [@updater]
66+ ; single_pane_width_threshold : int
77+ ; max_commits: int
88+}
99+[@@deriving yaml, record_updater ~derive:yaml]
41055-type t = { key_map : Key_map.key_config[@updater]; single_pane_width_threshold:int } [@@deriving yaml, record_updater ~derive: yaml]
66-77-88-let default_config:t =
99- {
1010- key_map= Key_map.default;
1111- single_pane_width_threshold=100;
1212- }
1313-;;
1111+let default_config : t = { key_map = Key_map.default; single_pane_width_threshold = 100; max_commits= 100}
14121513let get_config_dir () =
1614 let os = Os.poll_os () in
···2927 Filename.concat config_home "jj_tui"
3028;;
31293232-3330let load_config () =
3431 [%log info "Loading config..."];
3532 let config_file = Filename.concat (get_config_dir ()) "config.yaml" in
···3936 close_in ic;
4037 let json = Yaml.of_string_exn content in
4138 match t_update_t_of_yaml json with
4242- | Ok (config_update) ->
3939+ | Ok config_update ->
4340 [%log info "Config loaded!"];
4444- default_config |> t_apply_update config_update
4141+ default_config |> t_apply_update config_update
4542 | Error (`Msg msg) ->
4643 [%log warn "Error parsing config: %s" msg];
4744 default_config
+32-16
jj_tui/lib/process_wrappers.ml
···36363737let count_ansi str = str |> Re.all ansi_regex |> List.length
38383939-let find_selectable_from_graph str =
3939+let find_selectable_from_graph limit str =
4040 (* Matches a single revision in the format specificied by the graph template *)
4141 let matches =
4242 str
···4545 ~flags:[ Re.Pcre.(`MULTILINE) ]
4646 {|(^.*?)\$\$--START--\$\$\|(.+?)\|(.+?)\|(.+?)\|(.+?)\|([\s\S]*?)\$\$--END--\$\$\n?|})
4747 in
4848- let graph, ids =
4848+ let selectable_count = ref 0 in
4949+ let graph_rev, ids_rev =
4950 matches
5051 |> List.fold_left
5152 (fun (graph_acc, ids_acc) chunk ->
···6364 false
6465 | content ->
6566 failwith @@ "Couldn't parse jj divergent value:" ^ content
6666- in
6767+ in
6768 let hidden =
6869 match Re.Group.get selectable 5 |> remove_ansi with
6970 | "true" ->
···8081 commit_id
8182 (Re.Group.get selectable 6 |> remove_ansi)];
8283 let rev = { commit_id; change_id; divergent } in
8383- let id = if divergent || hidden then Duplicate commit_id else Unique change_id in
8484+ let id =
8585+ if divergent || hidden then Duplicate commit_id else Unique change_id
8686+ in
8487 let content = Re.Group.get selectable 6 in
8888+ incr selectable_count;
8589 `Selectable (graph_bit ^ content) :: graph_acc, id :: ids_acc
8690 | `Text filler ->
8791 (*Anything between our match is non-selectable filler*)
···8993 then graph_acc, ids_acc
9094 else `Filler filler :: graph_acc, ids_acc)
9195 ([], [])
9292- |> fun (graph, ids) -> List.rev graph |> Array.of_list, List.rev ids
9396 in
9494- let revs = ids in
9595- graph, revs
9797+ let graph =
9898+ (if !selectable_count >= (limit)
9999+ then (
100100+ [%log debug "limit: %d selectable: %d" limit !selectable_count];
101101+ let txt =
102102+ Printf.sprintf
103103+ "\nHit limit of %d items.\nIncrease limit in config or make your revset more \
104104+ precise\n"
105105+ limit
106106+ in
107107+ `Filler txt :: graph_rev)
108108+ else graph_rev)
109109+ |> List.rev
110110+ |> Array.of_list
111111+ in
112112+ graph, ids_rev |> List.rev
96113;;
9711498115module Make (Process : sig
···131148 ^ {|++"$$--END--$$"++""|}
132149 ;;
133150134134- let get_graph_info node_template revset_arg =
151151+ let get_graph_info node_template revset_arg limit =
135152 let output =
136136- jj_no_log ([ "log"; "-T"; graph_info_template node_template ] @ revset_arg)
153153+ jj_no_log ([ "log"; "-T"; graph_info_template node_template;"--limit"; limit |>string_of_int] @ revset_arg)
137154 in
138138- output |> find_selectable_from_graph
155155+ output |> find_selectable_from_graph limit
139156 ;;
140157141158 (** returns the graph and a list of revs within that graph*)
142142- let graph_and_revs ?revset () =
159159+ let graph_and_revs ?revset limit () =
143160 (*We join_after here to ensure any errors in sub-fibers only propegate to here, otherwise fibers everywhere would get cancelled when an error here occurs*)
144161 Flock.join_after @@ fun _ ->
145162 let graph =
146163 Flock.fork_as_promise @@ fun () ->
147164 let revset_arg = match revset with Some revset -> [ "-r"; revset ] | None -> [] in
148148- get_graph_info base_graph_template revset_arg
165165+ get_graph_info base_graph_template revset_arg limit
149166 in
150167 let graph, revs = Promise.await graph in
151168 graph, revs |> Array.of_list
···199216;;
200217201218let%expect_test "revs_graph_parsing" =
202202- let graph, ids = find_selectable_from_graph test_data_3 in
219219+ let graph, ids = find_selectable_from_graph 2000 test_data_3 in
203220 let ids = ids |> Array.of_list in
204221 let ids_idx = ref 0 in
205222 graph
···215232 | Unique id ->
216233 (* id.change_id |> print_endline; *)
217234 (* id.commit_id |> print_endline *)
218218- id|>print_endline
235235+ id |> print_endline
219236 | Duplicate id ->
220237 (* id.change_id |> print_endline; *)
221238 (* id.commit_id |> print_endline); *)
222222- id|>print_endline
223223- );
239239+ id |> print_endline);
224240 incr ids_idx;
225241 x |> print_endline);
226242 [%expect