let tag_files f_confirm tag files =
  match files with
    [] -> ()
  | _ ->
      check_tag tag ;
      (* check if some of the given files already have this tag. *)
      (* if yes, then the user must confirm, because the revision number
         associated to the tag will change. *)

      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 parts = partition_files_by_dir files in
        let f_part (d,l) =
          let com = Printf.sprintf
              "cd %s; cvs tag -F -c %s %s"
              (Filename.quote d)
              tag
              (List.fold_left (fun acc -> fun f -> acc^" "^(Filename.quote f)^"""" l)
          in
          let n = Sys.command com in
          if n = 0 then
            ()
          else
            raise (Ocvs_types.CvsFailure (Ocvs_messages.error_exec com))
        in
        List.iter f_part parts
      else
        ()