# # # patch "monotone.ml" # from [737dad9a128cc024e47dd1c73eef94b060702e5b] # to [06f5cd408dee52b1cc3e4b7b3c7dd72b6836bd83] # # patch "view.ml" # from [a05d8d4b2d95d01d940673f5adb1f8491b469514] # to [88b66de3800bbfc18f6663a9d753cf87f071a885] # ============================================================ --- monotone.ml 737dad9a128cc024e47dd1c73eef94b060702e5b +++ monotone.ml 06f5cd408dee52b1cc3e4b7b3c7dd72b6836bd83 @@ -92,8 +92,18 @@ let selectors_of_query q = | QUERY_NO_LIMIT -> List.map (fun b -> b, "b:" ^ b) q.dom | QUERY_BETWEEN (d1, d2) -> - let d = Printf.sprintf "l:%s/e:%s" d1 d2 in - List.map (fun b -> b, Printf.sprintf "%s/b:%s" d b) q.dom + let s_d = + match d1, d2 with + | "", "" -> [] + | d1, "" -> [ Printf.sprintf "l:%s" d1 ] + | "", d2 -> [ Printf.sprintf "e:%s" d2 ] + | d1, d2 -> [ Printf.sprintf "l:%s" d1 ; Printf.sprintf "e:%s" d2 ] in + List.map + (fun b -> + let s_b = Printf.sprintf "b:%s" b in + let s_t = String.concat "/" (s_b :: s_d) in + b, s_t) + q.dom let get_ids mtn query = List.fold_left @@ -115,6 +125,11 @@ let graph mtn = Automate.submit_sync mtn [ "graph" ] +let children mtn id f init = + Automate.submit_sync mtn [ "children" ; id ] + +> Viz_misc.string_split '\n' + +> List.fold_left f init + let decode_graph f init data = let pos = ref 0 in let acc = ref init in @@ -165,7 +180,15 @@ let interesting_node id_set id = let interesting_node id_set id = id_set = NodeMap.empty || NodeMap.mem id id_set -let add_node ids agraph id p = +let only_one_child mtn id = + children mtn id (fun n _ -> n + 1) 0 <= 1 + +let keep_neighbor_out mtn all_propagates p p_in_graph = + all_propagates + || List.length p_in_graph = List.length p + || List.for_all (only_one_child mtn) p_in_graph + +let add_node mtn query ids agraph id p = if interesting_node ids id then begin let agraph = @@ -187,18 +210,20 @@ let add_node ids agraph id p = match List.filter (interesting_node ids) p with | [] -> agraph - | p -> + | p_in_graph when keep_neighbor_out mtn query.all_propagates p p_in_graph -> let agraph = ensure_node agraph id NEIGHBOUR_OUT - (List.map (fun i -> i, PARENT) p) in + (List.map (fun i -> i, PARENT) p_in_graph) in List.fold_left (fun agraph id_p -> let agraph = ensure_node agraph id_p REGULAR [ id, CHILD ] in ensure_edge agraph ids id_p id) - agraph p + agraph p_in_graph + | _ -> + agraph let grab_tags mtn agraph = Automate.submit_sync mtn [ "tags" ] @@ -212,19 +237,13 @@ let grab_tags mtn agraph = with Not_found -> agraph) agraph -let children mtn id f init = - Automate.submit_sync mtn [ "children" ; id ] - +> Viz_misc.string_split '\n' - +> List.fold_left f init - let agraph mtn query = let ids = get_ids mtn query in graph mtn - +> decode_graph (add_node ids) empty_agraph + +> decode_graph (add_node mtn query ids) empty_agraph +> grab_tags mtn +> Components.reconnect (children mtn) (* TODO: - - the "all_propagates" switch - - get rid of "QUERY_ALL" + - distinguish between true neighbor nodes and nodes that are outside the date limit. *) ============================================================ --- view.ml a05d8d4b2d95d01d940673f5adb1f8491b469514 +++ view.ml 88b66de3800bbfc18f6663a9d753cf87f071a885 @@ -539,15 +539,12 @@ module Branch_selector = struct false) ; !acc - let future = "9999-12" - let past = "0001-01" - let make_query_limit_interval ctrl domain s_from s_to = - let t_from = Complete.complete_date ctrl domain - (if s_from = "" then past else s_from) in - let t_to = Complete.complete_date ctrl domain - (if s_to = "" then future else s_to) in - QUERY_BETWEEN (t_from, t_to) + let t_from = Complete.complete_date ctrl domain s_from in + let t_to = Complete.complete_date ctrl domain s_to in + if t_from = "" && t_to = "" + then QUERY_NO_LIMIT + else QUERY_BETWEEN (t_from, t_to) let make_query ctrl ?id s =