Debian Codegraph @

src/checkout/function.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::atomicrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/::AtomicBoolrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicBool#;
2
3 use gix_featuresrust-analyzer cargo gix-features 0.48.0 crate/::{interruptrust-analyzer cargo gix-features 0.48.0 interrupt/, parallelrust-analyzer cargo gix-features 0.48.0 parallel/::in_parallel_with_finalizerust-analyzer cargo gix-features 0.48.0 parallel/serial/in_parallel_with_finalize().};
4 use gix_worktreerust-analyzer cargo gix-worktree 0.52.0 crate/::{stackrust-analyzer cargo gix-worktree 0.52.0 stack/, Stackrust-analyzer cargo gix-worktree 0.52.0 Stack#};
5
6 use craterust-analyzer cargo gix-worktree-state 0.30.0 crate/::checkoutrust-analyzer cargo gix-worktree-state 0.30.0 checkout/::chunkrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/;
7
8 /// Checkout the entire `index` into `dir`, and resolve objects found in index entries with `objects` to write their content to their
9 /// respective path in `dir`.
10 /// Use `files` to count each fully checked out file, and count the amount written `bytes`. If `should_interrupt` is `true`, the
11 /// operation will abort.
12 /// `options` provide a lot of context on how to perform the operation.
13 ///
14 /// ### Handling the return value
15 ///
16 /// Note that interruption still produce an `Ok(…)` value, so the caller should look at `should_interrupt` to communicate the outcome.
17 ///
18 #[allow(clippy::too_many_arguments)]
19 pub fn checkoutrust-analyzer cargo gix-worktree-state 0.30.0 checkout/function/checkout().<Find>(
20 index: &mut gix_indexrust-analyzer cargo gix-index 0.51.0 crate/::Staterust-analyzer cargo gix-index 0.51.0 State#,
21 dir: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#>,
22 objects: Find,
23 files: &dyn gix_featuresrust-analyzer cargo gix-features 0.48.0 crate/::progressrust-analyzer cargo gix-features 0.48.0 progress/::Countrust-analyzer cargo prodash 31.0.0 traits/Count#,
24 bytes: &dyn gix_featuresrust-analyzer cargo gix-features 0.48.0 crate/::progressrust-analyzer cargo gix-features 0.48.0 progress/::Countrust-analyzer cargo prodash 31.0.0 traits/Count#,
25 should_interrupt: &AtomicBoolrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicBool#,
26 options: craterust-analyzer cargo gix-worktree-state 0.30.0 crate/::checkoutrust-analyzer cargo gix-worktree-state 0.30.0 checkout/::Optionsrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Options#,
27 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<craterust-analyzer cargo gix-worktree-state 0.30.0 crate/::checkoutrust-analyzer cargo gix-worktree-state 0.30.0 checkout/::Outcomerust-analyzer cargo gix-worktree-state 0.30.0 checkout/Outcome#, craterust-analyzer cargo gix-worktree-state 0.30.0 crate/::checkoutrust-analyzer cargo gix-worktree-state 0.30.0 checkout/::Errorrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Error#>
28 where
29 Find: gix_objectrust-analyzer cargo gix-object 0.60.0 crate/::Findrust-analyzer cargo gix-object 0.60.0 traits/find/Find# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
30 {
31 let paths = index.take_path_backingrust-analyzer cargo gix-index 0.51.0 access/impl#[State]take_path_backing().();
32 let res = checkout_innerrust-analyzer cargo gix-worktree-state 0.30.0 checkout/function/checkout_inner().(index, &paths, dir, objects, files, bytes, should_interrupt, options);
33 index.return_path_backingrust-analyzer cargo gix-index 0.51.0 access/impl#[State]return_path_backing().(paths);
34 res
35 }
36
37 #[allow(clippy::too_many_arguments)]
38 fn checkout_innerrust-analyzer cargo gix-worktree-state 0.30.0 checkout/function/checkout_inner().<Find>(
39 index: &mut gix_indexrust-analyzer cargo gix-index 0.51.0 crate/::Staterust-analyzer cargo gix-index 0.51.0 State#,
40 paths: &gix_indexrust-analyzer cargo gix-index 0.51.0 crate/::PathStoragerust-analyzer cargo gix-index 0.51.0 PathStorage#,
41 dir: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#>,
42 objects: Find,
43 files: &dyn gix_featuresrust-analyzer cargo gix-features 0.48.0 crate/::progressrust-analyzer cargo gix-features 0.48.0 progress/::Countrust-analyzer cargo prodash 31.0.0 traits/Count#,
44 bytes: &dyn gix_featuresrust-analyzer cargo gix-features 0.48.0 crate/::progressrust-analyzer cargo gix-features 0.48.0 progress/::Countrust-analyzer cargo prodash 31.0.0 traits/Count#,
45 should_interrupt: &AtomicBoolrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicBool#,
46 mut options: craterust-analyzer cargo gix-worktree-state 0.30.0 crate/::checkoutrust-analyzer cargo gix-worktree-state 0.30.0 checkout/::Optionsrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Options#,
47 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<craterust-analyzer cargo gix-worktree-state 0.30.0 crate/::checkoutrust-analyzer cargo gix-worktree-state 0.30.0 checkout/::Outcomerust-analyzer cargo gix-worktree-state 0.30.0 checkout/Outcome#, craterust-analyzer cargo gix-worktree-state 0.30.0 crate/::checkoutrust-analyzer cargo gix-worktree-state 0.30.0 checkout/::Errorrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Error#>
48 where
49 Find: gix_objectrust-analyzer cargo gix-object 0.60.0 crate/::Findrust-analyzer cargo gix-object 0.60.0 traits/find/Find# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
50 {
51 let num_files = files.counterrust-analyzer cargo prodash 31.0.0 traits/Count#counter().();
52 let num_bytes = bytes.counterrust-analyzer cargo prodash 31.0.0 traits/Count#counter().();
53 let dir = dir.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().();
54 let (chunk_size, thread_limit, num_threads) = gix_featuresrust-analyzer cargo gix-features 0.48.0 crate/::parallelrust-analyzer cargo gix-features 0.48.0 parallel/::optimize_chunk_size_and_thread_limitrust-analyzer cargo gix-features 0.48.0 parallel/optimize_chunk_size_and_thread_limit().(
55 100,
56 index.entriesrust-analyzer cargo gix-index 0.51.0 access/impl#[State]entries().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
57 options.thread_limitrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Options#thread_limit.,
58 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
59 );
60
61 let mut ctx = chunkrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/::Contextrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Context# {
62 bufrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Context#buf.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(),
63 optionsrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Context#options.: (&options).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
64 path_cacherust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Context#path_cache.: Stackrust-analyzer cargo gix-worktree 0.52.0 Stack#::from_state_and_ignore_caserust-analyzer cargo gix-worktree 0.52.0 stack/impl#[Stack]from_state_and_ignore_case().(
65 dir,
66 options.fsrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Options#fs..ignore_caserust-analyzer cargo gix-fs 0.21.0 Capabilities#ignore_case.,
67 stackrust-analyzer cargo gix-worktree 0.52.0 stack/::Staterust-analyzer cargo gix-worktree 0.52.0 stack/State#::for_checkoutrust-analyzer cargo gix-worktree 0.52.0 stack/state/impl#[State]for_checkout().(
68 options.overwrite_existingrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Options#overwrite_existing.,
69 options.validaterust-analyzer cargo gix-worktree-state 0.30.0 checkout/Options#validate.,
70 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/take().(&mut options.attributesrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Options#attributes.),
71 ),
72 index,
73 paths,
74 ),
75 filtersrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Context#filters.: options.filtersrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Options#filters.,
76 objectsrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Context#objects.,
77 };
78
79 let chunkrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/::Outcomerust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Outcome# {
80 mut collisionsrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Outcome#collisions.,
81 mut errorsrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Outcome#errors.,
82 mut bytes_writtenrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Outcome#bytes_written.,
83 filesrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Outcome#files.: files_updated,
84 delayed_symlinksrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Outcome#delayed_symlinks.,
85 delayed_paths_unknownrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Outcome#delayed_paths_unknown.,
86 delayed_paths_unprocessedrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Outcome#delayed_paths_unprocessed.,
87 } = if num_threads rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 {
88 let entries_with_paths = interruptrust-analyzer cargo gix-features 0.48.0 interrupt/::Iterrust-analyzer cargo gix-features 0.48.0 interrupt/Iter#::newrust-analyzer cargo gix-features 0.48.0 interrupt/impl#[`Iter<'a, I>`]new().(index.entries_mut_with_paths_inrust-analyzer cargo gix-index 0.51.0 access/impl#[State]entries_mut_with_paths_in().(paths), should_interrupt);
89 let mut delayed_filter_results = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
90 let mut out = chunkrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/::processrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/process().(
91 entries_with_paths,
92 &num_files,
93 &num_bytes,
94 &mut delayed_filter_results,
95 &mut ctx,
96 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
97 chunkrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/::process_delayed_filter_resultsrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/process_delayed_filter_results().(delayed_filter_results, &num_files, &num_bytes, &mut out, &mut ctx)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
98 out
99 } else {
100 let entries_with_paths = interruptrust-analyzer cargo gix-features 0.48.0 interrupt/::Iterrust-analyzer cargo gix-features 0.48.0 interrupt/Iter#::newrust-analyzer cargo gix-features 0.48.0 interrupt/impl#[`Iter<'a, I>`]new().(index.entries_mut_with_paths_inrust-analyzer cargo gix-index 0.51.0 access/impl#[State]entries_mut_with_paths_in().(paths), should_interrupt);
101 in_parallel_with_finalizerust-analyzer cargo gix-features 0.48.0 parallel/serial/in_parallel_with_finalize().(
102 gix_featuresrust-analyzer cargo gix-features 0.48.0 crate/::iterrust-analyzer cargo gix-features 0.48.0 iter/::Chunksrust-analyzer cargo gix-features 0.48.0 iter/Chunks# {
103 innerrust-analyzer cargo gix-features 0.48.0 iter/Chunks#inner.: entries_with_paths,
104 sizerust-analyzer cargo gix-features 0.48.0 iter/Chunks#size.: chunk_size,
105 },
106 thread_limit,
107 {
108 let ctx = ctx.clonerust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/impl#[`Context<Find>`][Clone]clone().();
109 move |_| (Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), ctx)
110 },
111 |chunk, (delayed_filter_results, ctx)| {
112 chunkrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/::processrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/process().(chunk.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), &num_files, &num_bytes, delayed_filter_results, ctx)
113 },
114 |(delayed_filter_results, mut ctx)| {
115 let mut out = chunkrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/::Outcomerust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/Outcome#::defaultrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/impl#[`Outcome<'a>`][Default]default().();
116 chunkrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/::process_delayed_filter_resultsrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/process_delayed_filter_results().(
117 delayed_filter_results,
118 &num_files,
119 &num_bytes,
120 &mut out,
121 &mut ctx,
122 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
123 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(out)
124 },
125 chunkrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/::Reducerust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/reduce/Reduce# {
126 aggregaterust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/reduce/Reduce#aggregate.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/impl#[`Outcome<'a>`][Default]default().(),
127 },
128 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
129 };
130
131 for (entry, entry_path) in delayed_symlinks {
132 bytes_written rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().chunkrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/::checkout_entry_handle_resultrust-analyzer cargo gix-worktree-state 0.30.0 checkout/chunk/checkout_entry_handle_result().(
133 entry,
134 entry_path,
135 &mut errors,
136 &mut collisions,
137 &num_files,
138 &num_bytes,
139 &mut ctx,
140 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
141 .as_bytesrust-analyzer cargo gix-worktree-state 0.30.0 checkout/entry/impl#[`Outcome<'_>`]as_bytes().()
142 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("only symlinks are delayed here, they are never filtered (or delayed again)")
143 as u64;
144 }
145
146 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(craterust-analyzer cargo gix-worktree-state 0.30.0 crate/::checkoutrust-analyzer cargo gix-worktree-state 0.30.0 checkout/::Outcomerust-analyzer cargo gix-worktree-state 0.30.0 checkout/Outcome# {
147 files_updatedrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Outcome#files_updated.,
148 collisionsrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Outcome#collisions.,
149 errorsrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Outcome#errors.,
150 bytes_writtenrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Outcome#bytes_written.,
151 delayed_paths_unknownrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Outcome#delayed_paths_unknown.,
152 delayed_paths_unprocessedrust-analyzer cargo gix-worktree-state 0.30.0 checkout/Outcome#delayed_paths_unprocessed.,
153 })
154 }