# # patch "database.ml" # from [194a3cd1f62997a8ce3e13f3f9016d5c9a968a9d] # to [d684e0564eaf8ace401d77b61906873c706f73f9] # # patch "database.mli" # from [6804358fa9ff99b1e19ef35995923db23eaa65c6] # to [587a34962c95fe2a1837b5df23e38a1c8acc3cbd] # # patch "view.ml" # from [8cffabcbe3db7aa326b6b5d20cc8ef48c2d7b49d] # to [8eedf028bdba7f8651a52f74647f88cd6bd75bac] # --- database.ml +++ database.ml @@ -372,15 +372,22 @@ let (_, rowid) = Hashtbl.find pubkeys id in rowid -let get_matching_tags db p = +let get_matching_cert db name p = List.rev (Sqlite3.fetch_f db.db (fun acc -> function - | [| id; tag |] when p tag -> (id, tag) :: acc + | [| id; v |] when p v -> (id, v) :: acc | _ -> acc) [] - "SELECT id, unbase64(value) FROM revision_certs WHERE name = 'tag'") + "SELECT id, unbase64(value) FROM revision_certs WHERE name = '%s'" name) +let get_matching_tags db p = + get_matching_cert db "tag" p + +let get_matching_dates db d_pref = + get_matching_cert db "date" + (string_is_prefix d_pref) + let run_monotone_diff db monotone_exe edge status cb = ignore (spawn_monotone_diff db.filename monotone_exe edge status cb) --- database.mli +++ database.mli @@ -16,7 +16,8 @@ val fetch_cert_signer : t -> string -> string -> string list val fetch_cert_value : t -> string -> string -> string list -val get_matching_tags : t -> (string -> bool) -> (string * string) list +val get_matching_tags : t -> (string -> bool) -> (string * string) list +val get_matching_dates : t -> string -> (string * string) list val get_key_rowid : t -> string -> int --- view.ml +++ view.ml @@ -357,6 +357,12 @@ ~label:"Include sub-branches" ~active:false ~packing:hb#pack () in let entry = GEdit.entry ~packing:(hb#pack ~from:`END) () in + begin + let tooltips = GData.tooltips () in + tooltips#set_tip + ~text:"Find a node by its revision id, tag or date (YYYY-MM-DD)" + entry#coerce + end ; let lbl = GMisc.label ~text:"Find:" ~packing:(hb#pack ~from:`END) () in let c = { combo = combo ; combo_signal = None ; @@ -854,18 +860,30 @@ then (k, n) :: acc else acc) nodes [] - let locate_tag v re = + 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 locate_with_db v f = let g = some v.agraph in - let db = Agraph.get_db g in List.map (fun (id, _) -> id, get_cnode v id) (List.sort (fun (_,a) (_,b) -> compare a b) (List.filter (fun (id, _) -> Agraph.mem g id) - (Database.get_matching_tags db - (fun v -> Str.string_match re v 0)))) + (f (Agraph.get_db g)))) + let locate_date v date_prefix = + locate_with_db v + (fun db -> Database.get_matching_dates db date_prefix) + + let locate_tag v re = + locate_with_db v + (fun db -> + Database.get_matching_tags db + (fun t -> Str.string_match re t 0)) + let locate v q = match v.find.last_find with | (last_q, n :: t) when last_q = q -> @@ -875,6 +893,8 @@ let candidates = if is_id q then locate_id v q + else if is_date q + then locate_date v q else try locate_tag v (Str.regexp q) with Failure _ -> [] in