diff --git a/src/build_system.ml b/src/build_system.ml index ec3987180aea..ac23598c0af3 100644 --- a/src/build_system.ml +++ b/src/build_system.ml @@ -194,7 +194,7 @@ module Alias0 = struct let dep_rec_internal ~name ~dir ~ctx_dir = Build.lazy_no_targets (lazy ( - File_tree.Dir.fold dir ~traverse_ignored_dirs:false ~traverse_vendored_dirs:false + File_tree.Dir.fold dir ~traverse_data_only_dirs:false ~traverse_vendored_dirs:false ~init:(Build.return true) ~f:(fun dir acc -> let path = Path.Build.append_source ctx_dir (File_tree.Dir.path dir) in @@ -1256,7 +1256,7 @@ and get_rule t path = let all_targets t = String.Map.to_list t.contexts |> List.fold_left ~init:Path.Build.Set.empty ~f:(fun acc (_, ctx) -> - File_tree.fold t.file_tree ~traverse_ignored_dirs:true ~traverse_vendored_dirs:true ~init:acc + File_tree.fold t.file_tree ~traverse_data_only_dirs:true ~traverse_vendored_dirs:true ~init:acc ~f:(fun dir acc -> match load_dir diff --git a/src/dune_load.ml b/src/dune_load.ml index fccc34ee3e52..ebb2d0d837ca 100644 --- a/src/dune_load.ml +++ b/src/dune_load.ml @@ -258,7 +258,7 @@ let interpret ~dir ~project ~ignore_promoted_rules let load ?(ignore_promoted_rules=false) ~ancestor_vcs () = let ftree = File_tree.load Path.Source.root ~ancestor_vcs in let projects = - File_tree.fold ftree ~traverse_ignored_dirs:false ~traverse_vendored_dirs:true ~init:[] + File_tree.fold ftree ~traverse_data_only_dirs:false ~traverse_vendored_dirs:true ~init:[] ~f:(fun dir acc -> let p = File_tree.Dir.project dir in if Path.Source.equal diff --git a/src/file_tree.ml b/src/file_tree.ml index 2f757d0a8267..cf3133816608 100644 --- a/src/file_tree.ml +++ b/src/file_tree.ml @@ -136,19 +136,19 @@ module Dir = struct String.Map.foldi (sub_dirs t) ~init:Path.Source.Set.empty ~f:(fun s _ acc -> Path.Source.Set.add acc (Path.Source.relative t.path s)) - let skip ~traverse_ignored_dirs ~traverse_vendored_dirs t = + let skip ~traverse_data_only_dirs ~traverse_vendored_dirs t = match t.status with - | Data_only -> not traverse_ignored_dirs + | Data_only -> not traverse_data_only_dirs | Vendored -> not traverse_vendored_dirs | Normal -> false - let rec fold t ~traverse_ignored_dirs ~traverse_vendored_dirs ~init:acc ~f = - if skip ~traverse_ignored_dirs ~traverse_vendored_dirs t then + let rec fold t ~traverse_data_only_dirs ~traverse_vendored_dirs ~init:acc ~f = + if skip ~traverse_data_only_dirs ~traverse_vendored_dirs t then acc else let acc = f t acc in String.Map.fold (sub_dirs t) ~init:acc ~f:(fun t acc -> - fold t ~traverse_ignored_dirs ~traverse_vendored_dirs ~init:acc ~f) + fold t ~traverse_data_only_dirs ~traverse_vendored_dirs ~init:acc ~f) let rec dyn_of_contents { files; sub_dirs; dune_file } = let open Dyn in @@ -397,7 +397,7 @@ let files_recursively_in t ~prefix_with path = match find_dir t path with | None -> Path.Set.empty | Some dir -> - Dir.fold dir ~init:Path.Set.empty ~traverse_ignored_dirs:true ~traverse_vendored_dirs:true + Dir.fold dir ~init:Path.Set.empty ~traverse_data_only_dirs:true ~traverse_vendored_dirs:true ~f:(fun dir acc -> let path = Path.append_source prefix_with (Dir.path dir) in String.Set.fold (Dir.files dir) ~init:acc ~f:(fun fn acc -> diff --git a/src/file_tree.mli b/src/file_tree.mli index dde6388a22b8..5c603f282192 100644 --- a/src/file_tree.mli +++ b/src/file_tree.mli @@ -50,7 +50,7 @@ module Dir : sig val fold : t - -> traverse_ignored_dirs:bool + -> traverse_data_only_dirs:bool -> traverse_vendored_dirs:bool -> init:'a -> f:(t -> 'a -> 'a) @@ -77,12 +77,12 @@ val load -> ancestor_vcs:Vcs.t option -> t -(** Passing [~traverse_ignored_dirs:true] to this functions causes the +(** Passing [~traverse_data_only_dirs:true] to this functions causes the whole source tree to be deeply scanned, including ignored sub-trees. *) val fold : t - -> traverse_ignored_dirs:bool + -> traverse_data_only_dirs:bool -> traverse_vendored_dirs:bool -> init:'a -> f:(Dir.t -> 'a -> 'a) diff --git a/src/upgrader.ml b/src/upgrader.ml index 29edd94b839b..9c0fceffc7da 100644 --- a/src/upgrader.ml +++ b/src/upgrader.ml @@ -374,7 +374,7 @@ let upgrade ft = ; to_edit = [] } in - File_tree.fold ft ~traverse_ignored_dirs:false ~traverse_vendored_dirs:false ~init:() + File_tree.fold ft ~traverse_data_only_dirs:false ~traverse_vendored_dirs:false ~init:() ~f:(fun dir () -> upgrade_dir todo dir); let git = lazy ( match Bin.which ~path:(Env.path Env.initial) "git" with diff --git a/src/utop.ml b/src/utop.ml index 3d9782863b51..944407b151df 100644 --- a/src/utop.ml +++ b/src/utop.ml @@ -26,7 +26,7 @@ let libs_under_dir sctx ~db ~dir = (let open Option.O in let* dir = Path.drop_build_context dir in let+ dir = File_tree.find_dir (Super_context.file_tree sctx) dir in - File_tree.Dir.fold dir ~traverse_ignored_dirs:true ~traverse_vendored_dirs:true + File_tree.Dir.fold dir ~traverse_data_only_dirs:true ~traverse_vendored_dirs:true ~init:[] ~f:(fun dir acc -> let dir = Path.Build.append_source (Super_context.build_dir sctx)