# # # patch "database.mli" # from [5f231088c57966518dc227dc3e5e845edfff2a2c] # to [b1385c2a04cb713ef644ea246f0257ae7d712ca2] # # patch "view.ml" # from [7e754e5dd6de0204256cabf4033997be4e6ba17d] # to [2b7975b76ad4df6b4c97fdf20d223e9fae3c5e61] # ============================================================ --- database.mli 5f231088c57966518dc227dc3e5e845edfff2a2c +++ database.mli b1385c2a04cb713ef644ea246f0257ae7d712ca2 @@ -13,12 +13,6 @@ val fetch_ancestry_graph : t -> query -> val fetch_ancestry_graph : t -> query -> agraph -val get_matching_tags : t -> (string -> bool) -> (string * string) list -val get_matching_dates : t -> string -> (string * string) list -val get_matching_ids : t -> string -> (string * string) list - -(* val get_key_rowid : t -> string -> int *) - val run_monotone_diff : t -> string -> unit; pop : unit -> unit; ..> -> ============================================================ --- view.ml 7e754e5dd6de0204256cabf4033997be4e6ba17d +++ view.ml 2b7975b76ad4df6b4c97fdf20d223e9fae3c5e61 @@ -296,43 +296,10 @@ module Complete = struct module Complete = struct - let is_id = - let re = Str.regexp "^[0-9a-fA-F]+$" in - fun id -> Str.string_match re id 0 - let is_date = let re = Str.regexp "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" in fun id -> Str.string_partial_match re id 0 - let complete_with_db ctrl f = - match ctrl#get_db with - | None -> [] - | Some db -> f db - - let complete_id ctrl query_domain q = - complete_with_db ctrl - (fun db -> - let data = Database.get_matching_ids db q in - match query_domain with - | QUERY_ALL -> data - | QUERY_BRANCHES allowed_branches -> - List.filter - (fun (_, branch_name) -> List.mem branch_name allowed_branches) - data) - - let complete_tag ctrl q = - complete_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 get_id_and_uniquify data = - data - ++ List.map fst - ++ List.sort compare - ++ Viz_misc.list_uniq - let several_completions parent (t, ids) = let txt = Buffer.create 128 in Printf.bprintf txt @@ -354,27 +321,26 @@ module Complete = struct ignore (m#connect#response (fun _ -> m#destroy ())) ; m#show () - exception None + exception None_ exception Many of (string * string list) let complete_date ctrl domain t = if is_date t then t else - let match_data = - if is_id t - then complete_id ctrl domain t - else complete_tag ctrl t in - match get_id_and_uniquify match_data with - | [] -> raise None - | [ id ] -> - begin - match Monotone.cert_value (some ctrl#get_mtn) id "date" with - | t :: _ -> t - | [] -> raise None - end - | ids -> - raise (Many (t, ids)) + match ctrl#get_mtn with + | None -> raise None_ + | Some mtn -> + match Monotone.select mtn t with + | [] -> raise None_ + | [ id ] -> + begin + match Monotone.cert_value mtn id "date" with + | t :: _ -> t + | [] -> raise None_ + end + | ids -> + raise (Many (t, ids)) end @@ -605,7 +571,7 @@ module Branch_selector = struct all_propagates = query_propagate }; preselect = id } with - | Complete.None -> None + | Complete.None_ -> None | Complete.Many compl -> Complete.several_completions s.w compl ; None