# # # patch "monotone.ml" # from [b795d056419d26139527e11d892e638e28f4124e] # to [3f63dcb34f5c5181bef95b8a5c8679928fb700b2] # # patch "monotone.mli" # from [f6a7fc93b416ed251f8096bad2812c4157325dea] # to [501932e7b04b87a18442dd08c930e54f907c3474] # # patch "view.ml" # from [7b1e9f8c8bfe323b136cd77aae6ff6c8853fe810] # to [7e754e5dd6de0204256cabf4033997be4e6ba17d] # ============================================================ --- monotone.ml b795d056419d26139527e11d892e638e28f4124e +++ monotone.ml 3f63dcb34f5c5181bef95b8a5c8679928fb700b2 @@ -74,3 +74,10 @@ let cert_value mtn id name = raw_certs mtn id +> List.filter (fun st -> get_elem st "name" = name) +> List.map (fun st -> get_elem st "value") + + +let select mtn selector = + Automate.submit_sync + mtn [ "select" ; selector ] + +> Viz_misc.string_split '\n' + ============================================================ --- monotone.mli f6a7fc93b416ed251f8096bad2812c4157325dea +++ monotone.mli 501932e7b04b87a18442dd08c930e54f907c3474 @@ -8,3 +8,4 @@ val cert_value : t -> string -> string - val get_revision : t -> string -> Viz_types.node_data val get_certs_and_revision : t -> string -> Viz_types.node_data val cert_value : t -> string -> string -> string list +val select : t -> string -> string list ============================================================ --- view.ml 7b1e9f8c8bfe323b136cd77aae6ff6c8853fe810 +++ view.ml 7e754e5dd6de0204256cabf4033997be4e6ba17d @@ -1400,7 +1400,7 @@ module Find = struct begin let tooltips = GData.tooltips () in tooltips#set_tip - ~text:"Find a node by its revision id, tag or date (YYYY-MM-DD)" + ~text:"Find a node using a monotone selector" entry#coerce end ; add_label ~text:"Find:" ~packing ; @@ -1414,58 +1414,29 @@ module Find = struct find.find_entry#set_text "" ; find.last_find <- "", [] - let locate_id ctrl id = + let order lr_layout (_, n1) (_, n2) = + if lr_layout + then compare n1.n_x n2.n_x + else compare n1.n_y n2.n_y + + let filter_in_agraph ctrl ids = match ctrl#get_agraph with | None -> [] | Some g -> - let id = String.lowercase id in - if String.length id < 2 - then [] - else - NodeMap.fold - (fun k n acc -> - if string_is_prefix id k - then (k, n) :: acc - else acc) - (Agraph.get_layout g).c_nodes [] + ids + ++ List.filter (Agraph.mem g) + ++ List.map (Agraph.get_node g) + ++ List.sort (order ctrl#get_prefs.Viz_style.lr_layout) + - let locate_with_db ctrl f = - match ctrl#get_db with - | None -> [] - | Some db -> - match ctrl#get_agraph with - | None -> [] - | Some g -> - f db - ++ List.filter (fun (id, _) -> Agraph.mem g id) - ++ List.sort (fun (_,a) (_,b) -> compare a b) - ++ List.map (fun (id, _) -> Agraph.get_node g id) - - let locate_date ctrl date_prefix = - locate_with_db ctrl - (fun db -> Database.get_matching_dates db date_prefix) - - let locate_tag ctrl q = - locate_with_db ctrl - (fun db -> - let re = Str.regexp q in - Database.get_matching_tags db - (fun t -> Str.string_match re t 0)) - let locate find ctrl q = match find.last_find with | (last_q, n :: t) when last_q = q -> find.last_find <- (last_q, t) ; ctrl#center_on n | _ -> - let candidates = - try - if Complete.is_id q - then locate_id ctrl q - else if Complete.is_date q - then locate_date ctrl q - else locate_tag ctrl q - with Failure _ | Invalid_argument _ -> [] in + let ids = Monotone.select (some ctrl#get_mtn) q in + let candidates = filter_in_agraph ctrl ids in match candidates with | [] -> find.last_find <- (q, [])