Debian Codegraph @

cli/src/commands/debug/local_working_copy.rs

raw
1 // Copyright 2023 The Jujutsu Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 use std::fmt::Debug;
16 use std::io::Write as _;
17
18 use jj_lib::working_copy::WorkingCopy as _;
19
20 use super::check_local_disk_wc;
21 use crate::cli_util::CommandHelper;
22 use crate::command_error::CommandError;
23 use crate::ui::Ui;
24
25 /// Show information about the local working copy state
26 ///
27 /// This command only works with a standard local-disk working copy.
28 #[derive(clap::Args, Clone, Debug)]
29 pub struct DebugLocalWorkingCopyArgs {}
30
31 pub async fn cmd_debug_local_working_copy(
32 ui: &mut Ui,
33 command: &CommandHelper,
34 _args: &DebugLocalWorkingCopyArgs,
35 ) -> Result<(), CommandError> {
36 let workspace_command = command.workspace_helper(ui).await?;
37 let wc = check_local_disk_wc(workspace_command.working_copy())?;
38 writeln!(ui.stdout(), "Current operation: {:?}", wc.operation_id())?;
39 writeln!(ui.stdout(), "Current tree: {:?}", wc.tree()?)?;
40 for (file, state) in wc.file_states()? {
41 writeln!(
42 ui.stdout(),
43 "{:?} {:13?} {:10?} {:?} {:?}",
44 state.file_type,
45 state.size,
46 state.mtime.0,
47 state.materialized_conflict_data,
48 file
49 )?;
50 }
51 Ok(())
52 }