just playing with tangled
at ig/vimdiffwarn 112 lines 4.2 kB view 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 15mod copy_detection; 16mod fileset; 17mod index; 18mod init_simple; 19mod local_working_copy; 20mod operation; 21mod reindex; 22mod revset; 23mod snapshot; 24mod template; 25mod tree; 26mod watchman; 27mod working_copy; 28 29use std::any::Any; 30use std::fmt::Debug; 31 32use clap::Subcommand; 33use jj_lib::local_working_copy::LocalWorkingCopy; 34 35use self::copy_detection::cmd_debug_copy_detection; 36use self::copy_detection::CopyDetectionArgs; 37use self::fileset::cmd_debug_fileset; 38use self::fileset::DebugFilesetArgs; 39use self::index::cmd_debug_index; 40use self::index::DebugIndexArgs; 41use self::init_simple::cmd_debug_init_simple; 42use self::init_simple::DebugInitSimpleArgs; 43use self::local_working_copy::cmd_debug_local_working_copy; 44use self::local_working_copy::DebugLocalWorkingCopyArgs; 45use self::operation::cmd_debug_operation; 46use self::operation::DebugOperationArgs; 47use self::reindex::cmd_debug_reindex; 48use self::reindex::DebugReindexArgs; 49use self::revset::cmd_debug_revset; 50use self::revset::DebugRevsetArgs; 51use self::snapshot::cmd_debug_snapshot; 52use self::snapshot::DebugSnapshotArgs; 53use self::template::cmd_debug_template; 54use self::template::DebugTemplateArgs; 55use self::tree::cmd_debug_tree; 56use self::tree::DebugTreeArgs; 57use self::watchman::cmd_debug_watchman; 58use self::watchman::DebugWatchmanCommand; 59use self::working_copy::cmd_debug_working_copy; 60use self::working_copy::DebugWorkingCopyArgs; 61use crate::cli_util::CommandHelper; 62use crate::command_error::user_error; 63use crate::command_error::CommandError; 64use crate::ui::Ui; 65 66/// Low-level commands not intended for users 67#[derive(Subcommand, Clone, Debug)] 68#[command(hide = true)] 69pub enum DebugCommand { 70 CopyDetection(CopyDetectionArgs), 71 Fileset(DebugFilesetArgs), 72 Index(DebugIndexArgs), 73 InitSimple(DebugInitSimpleArgs), 74 LocalWorkingCopy(DebugLocalWorkingCopyArgs), 75 #[command(visible_alias = "view")] 76 Operation(DebugOperationArgs), 77 Reindex(DebugReindexArgs), 78 Revset(DebugRevsetArgs), 79 Snapshot(DebugSnapshotArgs), 80 Template(DebugTemplateArgs), 81 Tree(DebugTreeArgs), 82 #[command(subcommand)] 83 Watchman(DebugWatchmanCommand), 84 WorkingCopy(DebugWorkingCopyArgs), 85} 86 87pub fn cmd_debug( 88 ui: &mut Ui, 89 command: &CommandHelper, 90 subcommand: &DebugCommand, 91) -> Result<(), CommandError> { 92 match subcommand { 93 DebugCommand::CopyDetection(args) => cmd_debug_copy_detection(ui, command, args), 94 DebugCommand::Fileset(args) => cmd_debug_fileset(ui, command, args), 95 DebugCommand::Index(args) => cmd_debug_index(ui, command, args), 96 DebugCommand::InitSimple(args) => cmd_debug_init_simple(ui, command, args), 97 DebugCommand::LocalWorkingCopy(args) => cmd_debug_local_working_copy(ui, command, args), 98 DebugCommand::Operation(args) => cmd_debug_operation(ui, command, args), 99 DebugCommand::Reindex(args) => cmd_debug_reindex(ui, command, args), 100 DebugCommand::Revset(args) => cmd_debug_revset(ui, command, args), 101 DebugCommand::Snapshot(args) => cmd_debug_snapshot(ui, command, args), 102 DebugCommand::Template(args) => cmd_debug_template(ui, command, args), 103 DebugCommand::Tree(args) => cmd_debug_tree(ui, command, args), 104 DebugCommand::Watchman(args) => cmd_debug_watchman(ui, command, args), 105 DebugCommand::WorkingCopy(args) => cmd_debug_working_copy(ui, command, args), 106 } 107} 108 109fn check_local_disk_wc(x: &dyn Any) -> Result<&LocalWorkingCopy, CommandError> { 110 x.downcast_ref() 111 .ok_or_else(|| user_error("This command requires a standard local-disk working copy")) 112}