let tag_dir ?(recursive=true) f_confirm tag dir =
  check_tag tag ;
  (* check if some of the files in the directory or one of its subidrs
     already have this tag. *)

  (* if yes, then the user must confirm, because the revision number
     associated to the tag will change. *)

  let files = get_cvs_files dir in
  let (ko, ok) = List.partition (file_has_tag tag) files in
  let continue =
    (ko = []) || f_confirm (Ocvs_messages.files_already_has_tag ko tag)
  in
  if continue then
    let com = Printf.sprintf
      "cd %s ; cvs tag %s -F -c %s"
        (Filename.quote dir)
        (if recursive then "-R" else "-l")
        tag
    in
    let n = Sys.command com in
    if n = 0 then
      ()
    else
      raise (Ocvs_types.CvsFailure (Ocvs_messages.error_exec com))
  else
    ()