diff --git a/Cargo.toml b/Cargo.toml index 1512fcbfa..651455535 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ members = ["cli", "lib", "lib/gen-protos", "lib/proc-macros", "lib/testutils"] version = "0.31.0" license = "Apache-2.0" rust-version = "1.85" # NOTE: remember to update CI, contributing.md, changelog.md, and install-and-setup.md -edition = "2021" +edition = "2024" readme = "README.md" homepage = "https://github.com/jj-vcs/jj" repository = "https://github.com/jj-vcs/jj" diff --git a/cli/src/cleanup_guard.rs b/cli/src/cleanup_guard.rs index b6185458c..b3bb9e51a 100644 --- a/cli/src/cleanup_guard.rs +++ b/cli/src/cleanup_guard.rs @@ -55,9 +55,9 @@ mod platform { use std::sync::atomic::Ordering; use std::thread; - use libc::c_int; use libc::SIGINT; use libc::SIGTERM; + use libc::c_int; use super::*; diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index c2043213b..cc4f30cc6 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -35,16 +35,16 @@ use std::time::SystemTime; use bstr::ByteVec as _; use chrono::TimeZone as _; +use clap::ArgAction; +use clap::ArgMatches; +use clap::Command; +use clap::FromArgMatches as _; use clap::builder::MapValueParser; use clap::builder::NonEmptyStringValueParser; use clap::builder::TypedValueParser as _; use clap::builder::ValueParserFactory; use clap::error::ContextKind; use clap::error::ContextValue; -use clap::ArgAction; -use clap::ArgMatches; -use clap::Command; -use clap::FromArgMatches as _; use clap_complete::ArgValueCandidates; use clap_complete::ArgValueCompleter; use indexmap::IndexMap; @@ -87,7 +87,6 @@ use jj_lib::ref_name::RefName; use jj_lib::ref_name::RefNameBuf; use jj_lib::ref_name::WorkspaceName; use jj_lib::ref_name::WorkspaceNameBuf; -use jj_lib::repo::merge_factories_map; use jj_lib::repo::CheckOutCommitError; use jj_lib::repo::EditCommitError; use jj_lib::repo::MutableRepo; @@ -96,6 +95,7 @@ use jj_lib::repo::Repo; use jj_lib::repo::RepoLoader; use jj_lib::repo::StoreFactories; use jj_lib::repo::StoreLoadError; +use jj_lib::repo::merge_factories_map; use jj_lib::repo_path::RepoPath; use jj_lib::repo_path::RepoPathBuf; use jj_lib::repo_path::RepoPathUiConverter; @@ -129,8 +129,6 @@ use jj_lib::working_copy::UntrackedReason; use jj_lib::working_copy::WorkingCopy; use jj_lib::working_copy::WorkingCopyFactory; use jj_lib::working_copy::WorkingCopyFreshness; -use jj_lib::workspace::default_working_copy_factories; -use jj_lib::workspace::get_working_copy_factory; use jj_lib::workspace::DefaultWorkspaceLoaderFactory; use jj_lib::workspace::LockedWorkspace; use jj_lib::workspace::WorkingCopyFactories; @@ -138,11 +136,14 @@ use jj_lib::workspace::Workspace; use jj_lib::workspace::WorkspaceLoadError; use jj_lib::workspace::WorkspaceLoader; use jj_lib::workspace::WorkspaceLoaderFactory; +use jj_lib::workspace::default_working_copy_factories; +use jj_lib::workspace::get_working_copy_factory; use pollster::FutureExt as _; use tracing::instrument; use tracing_chrome::ChromeLayerBuilder; use tracing_subscriber::prelude::*; +use crate::command_error::CommandError; use crate::command_error::cli_error; use crate::command_error::config_error_with_message; use crate::command_error::handle_command_result; @@ -151,15 +152,14 @@ use crate::command_error::internal_error_with_message; use crate::command_error::print_parse_diagnostics; use crate::command_error::user_error; use crate::command_error::user_error_with_hint; -use crate::command_error::CommandError; use crate::commit_templater::CommitTemplateLanguage; use crate::commit_templater::CommitTemplateLanguageExtension; use crate::complete; -use crate::config::config_from_environment; -use crate::config::parse_config_args; use crate::config::ConfigArgKind; use crate::config::ConfigEnv; use crate::config::RawConfig; +use crate::config::config_from_environment; +use crate::config::parse_config_args; use crate::description_util::TextEditor; use crate::diff_util; use crate::diff_util::DiffFormat; diff --git a/cli/src/commands/abandon.rs b/cli/src/commands/abandon.rs index e46be8251..bda89568f 100644 --- a/cli/src/commands/abandon.rs +++ b/cli/src/commands/abandon.rs @@ -24,11 +24,11 @@ use jj_lib::revset::RevsetExpression; use jj_lib::rewrite::RewriteRefsOptions; use tracing::instrument; +use crate::cli_util::CommandHelper; +use crate::cli_util::RevisionArg; #[cfg(feature = "git")] use crate::cli_util::has_tracked_remote_bookmarks; use crate::cli_util::print_updated_commits; -use crate::cli_util::CommandHelper; -use crate::cli_util::RevisionArg; use crate::command_error::CommandError; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/absorb.rs b/cli/src/commands/absorb.rs index c23c178e6..9728cff6d 100644 --- a/cli/src/commands/absorb.rs +++ b/cli/src/commands/absorb.rs @@ -13,16 +13,16 @@ // limitations under the License. use clap_complete::ArgValueCompleter; +use jj_lib::absorb::AbsorbSource; use jj_lib::absorb::absorb_hunks; use jj_lib::absorb::split_hunks_to_trees; -use jj_lib::absorb::AbsorbSource; use jj_lib::matchers::EverythingMatcher; use pollster::FutureExt as _; use tracing::instrument; -use crate::cli_util::print_updated_commits; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; +use crate::cli_util::print_updated_commits; use crate::command_error::CommandError; use crate::complete; use crate::diff_util::DiffFormat; diff --git a/cli/src/commands/bench/common_ancestors.rs b/cli/src/commands/bench/common_ancestors.rs index feafa9dc1..5fd4bfa1b 100644 --- a/cli/src/commands/bench/common_ancestors.rs +++ b/cli/src/commands/bench/common_ancestors.rs @@ -16,8 +16,8 @@ use std::slice; use jj_lib::repo::Repo as _; -use super::run_bench; use super::CriterionArgs; +use super::run_bench; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; use crate::command_error::CommandError; diff --git a/cli/src/commands/bench/is_ancestor.rs b/cli/src/commands/bench/is_ancestor.rs index c0629d9ab..b41c7231b 100644 --- a/cli/src/commands/bench/is_ancestor.rs +++ b/cli/src/commands/bench/is_ancestor.rs @@ -14,8 +14,8 @@ use jj_lib::repo::Repo as _; -use super::run_bench; use super::CriterionArgs; +use super::run_bench; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; use crate::command_error::CommandError; diff --git a/cli/src/commands/bench/mod.rs b/cli/src/commands/bench/mod.rs index 79eb32c0d..ad4355260 100644 --- a/cli/src/commands/bench/mod.rs +++ b/cli/src/commands/bench/mod.rs @@ -24,14 +24,14 @@ use std::time::Instant; use clap::Subcommand; use criterion::Criterion; -use self::common_ancestors::cmd_bench_common_ancestors; use self::common_ancestors::BenchCommonAncestorsArgs; -use self::is_ancestor::cmd_bench_is_ancestor; +use self::common_ancestors::cmd_bench_common_ancestors; use self::is_ancestor::BenchIsAncestorArgs; -use self::resolve_prefix::cmd_bench_resolve_prefix; +use self::is_ancestor::cmd_bench_is_ancestor; use self::resolve_prefix::BenchResolvePrefixArgs; -use self::revset::cmd_bench_revset; +use self::resolve_prefix::cmd_bench_resolve_prefix; use self::revset::BenchRevsetArgs; +use self::revset::cmd_bench_revset; use crate::cli_util::CommandHelper; use crate::command_error::CommandError; use crate::ui::Ui; diff --git a/cli/src/commands/bench/resolve_prefix.rs b/cli/src/commands/bench/resolve_prefix.rs index e952fff6b..f36edf937 100644 --- a/cli/src/commands/bench/resolve_prefix.rs +++ b/cli/src/commands/bench/resolve_prefix.rs @@ -15,8 +15,8 @@ use jj_lib::object_id::HexPrefix; use jj_lib::repo::Repo as _; -use super::run_bench; use super::CriterionArgs; +use super::run_bench; use crate::cli_util::CommandHelper; use crate::command_error::CommandError; use crate::ui::Ui; diff --git a/cli/src/commands/bench/revset.rs b/cli/src/commands/bench/revset.rs index 5b4bb26a1..b544e8abc 100644 --- a/cli/src/commands/bench/revset.rs +++ b/cli/src/commands/bench/revset.rs @@ -15,16 +15,16 @@ use std::rc::Rc; use std::time::Instant; -use criterion::measurement::Measurement; use criterion::BatchSize; use criterion::BenchmarkGroup; use criterion::BenchmarkId; +use criterion::measurement::Measurement; use jj_lib::revset::SymbolResolver; use jj_lib::revset::SymbolResolverExtension; use jj_lib::revset::UserRevsetExpression; -use super::new_criterion; use super::CriterionArgs; +use super::new_criterion; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; use crate::cli_util::WorkspaceCommandHelper; diff --git a/cli/src/commands/bookmark/create.rs b/cli/src/commands/bookmark/create.rs index cfe8804f9..9cd14cc7b 100644 --- a/cli/src/commands/bookmark/create.rs +++ b/cli/src/commands/bookmark/create.rs @@ -18,11 +18,11 @@ use jj_lib::object_id::ObjectId as _; use jj_lib::op_store::RefTarget; use jj_lib::ref_name::RefNameBuf; -use crate::cli_util::has_tracked_remote_bookmarks; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; -use crate::command_error::user_error_with_hint; +use crate::cli_util::has_tracked_remote_bookmarks; use crate::command_error::CommandError; +use crate::command_error::user_error_with_hint; use crate::complete; use crate::revset_util; use crate::ui::Ui; diff --git a/cli/src/commands/bookmark/mod.rs b/cli/src/commands/bookmark/mod.rs index 9c862a3ed..8288e9da5 100644 --- a/cli/src/commands/bookmark/mod.rs +++ b/cli/src/commands/bookmark/mod.rs @@ -32,28 +32,28 @@ use jj_lib::repo::Repo; use jj_lib::str_util::StringPattern; use jj_lib::view::View; -use self::create::cmd_bookmark_create; use self::create::BookmarkCreateArgs; -use self::delete::cmd_bookmark_delete; +use self::create::cmd_bookmark_create; use self::delete::BookmarkDeleteArgs; -use self::forget::cmd_bookmark_forget; +use self::delete::cmd_bookmark_delete; use self::forget::BookmarkForgetArgs; -use self::list::cmd_bookmark_list; +use self::forget::cmd_bookmark_forget; use self::list::BookmarkListArgs; -use self::r#move::cmd_bookmark_move; +use self::list::cmd_bookmark_list; use self::r#move::BookmarkMoveArgs; -use self::rename::cmd_bookmark_rename; +use self::r#move::cmd_bookmark_move; use self::rename::BookmarkRenameArgs; -use self::set::cmd_bookmark_set; +use self::rename::cmd_bookmark_rename; use self::set::BookmarkSetArgs; -use self::track::cmd_bookmark_track; +use self::set::cmd_bookmark_set; use self::track::BookmarkTrackArgs; -use self::untrack::cmd_bookmark_untrack; +use self::track::cmd_bookmark_track; use self::untrack::BookmarkUntrackArgs; +use self::untrack::cmd_bookmark_untrack; use crate::cli_util::CommandHelper; use crate::cli_util::RemoteBookmarkNamePattern; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::ui::Ui; // Unlike most other aliases, `b` is defined in the config and can be overridden diff --git a/cli/src/commands/bookmark/move.rs b/cli/src/commands/bookmark/move.rs index 01bfff0c6..59ffa0fec 100644 --- a/cli/src/commands/bookmark/move.rs +++ b/cli/src/commands/bookmark/move.rs @@ -23,8 +23,8 @@ use super::find_bookmarks_with; use super::is_fast_forward; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; -use crate::command_error::user_error_with_hint; use crate::command_error::CommandError; +use crate::command_error::user_error_with_hint; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/bookmark/rename.rs b/cli/src/commands/bookmark/rename.rs index 48f06afba..7f2cded09 100644 --- a/cli/src/commands/bookmark/rename.rs +++ b/cli/src/commands/bookmark/rename.rs @@ -16,10 +16,10 @@ use clap_complete::ArgValueCandidates; use jj_lib::op_store::RefTarget; use jj_lib::ref_name::RefNameBuf; -use crate::cli_util::has_tracked_remote_bookmarks; use crate::cli_util::CommandHelper; -use crate::command_error::user_error; +use crate::cli_util::has_tracked_remote_bookmarks; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::complete; use crate::revset_util; use crate::ui::Ui; diff --git a/cli/src/commands/bookmark/set.rs b/cli/src/commands/bookmark/set.rs index cd5fc27e1..162618a5e 100644 --- a/cli/src/commands/bookmark/set.rs +++ b/cli/src/commands/bookmark/set.rs @@ -20,11 +20,11 @@ use jj_lib::op_store::RefTarget; use jj_lib::ref_name::RefNameBuf; use super::is_fast_forward; -use crate::cli_util::has_tracked_remote_bookmarks; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; -use crate::command_error::user_error_with_hint; +use crate::cli_util::has_tracked_remote_bookmarks; use crate::command_error::CommandError; +use crate::command_error::user_error_with_hint; use crate::complete; use crate::revset_util; use crate::ui::Ui; diff --git a/cli/src/commands/commit.rs b/cli/src/commands/commit.rs index 263935bcc..9d14dc6be 100644 --- a/cli/src/commands/commit.rs +++ b/cli/src/commands/commit.rs @@ -21,8 +21,8 @@ use jj_lib::repo::Repo as _; use tracing::instrument; use crate::cli_util::CommandHelper; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::complete; use crate::description_util::add_trailers; use crate::description_util::description_template; diff --git a/cli/src/commands/config/edit.rs b/cli/src/commands/config/edit.rs index b88a66adf..3ca0ba908 100644 --- a/cli/src/commands/config/edit.rs +++ b/cli/src/commands/config/edit.rs @@ -17,8 +17,8 @@ use tracing::instrument; use super::ConfigLevelArgs; use crate::cli_util::CommandHelper; -use crate::command_error::print_error_sources; use crate::command_error::CommandError; +use crate::command_error::print_error_sources; use crate::ui::Ui; /// Start an editor on a jj config file. diff --git a/cli/src/commands/config/list.rs b/cli/src/commands/config/list.rs index 50beb31ca..a98b4ed1e 100644 --- a/cli/src/commands/config/list.rs +++ b/cli/src/commands/config/list.rs @@ -22,8 +22,8 @@ use super::ConfigLevelArgs; use crate::cli_util::CommandHelper; use crate::command_error::CommandError; use crate::complete; -use crate::config::resolved_config_values; use crate::config::AnnotatedValue; +use crate::config::resolved_config_values; use crate::generic_templater; use crate::generic_templater::GenericTemplateLanguage; use crate::templater::TemplatePropertyExt as _; diff --git a/cli/src/commands/config/mod.rs b/cli/src/commands/config/mod.rs index b11769eb2..f8223cc95 100644 --- a/cli/src/commands/config/mod.rs +++ b/cli/src/commands/config/mod.rs @@ -26,21 +26,21 @@ use jj_lib::config::ConfigFile; use jj_lib::config::ConfigSource; use tracing::instrument; -use self::edit::cmd_config_edit; use self::edit::ConfigEditArgs; -use self::get::cmd_config_get; +use self::edit::cmd_config_edit; use self::get::ConfigGetArgs; -use self::list::cmd_config_list; +use self::get::cmd_config_get; use self::list::ConfigListArgs; -use self::path::cmd_config_path; +use self::list::cmd_config_list; use self::path::ConfigPathArgs; -use self::set::cmd_config_set; +use self::path::cmd_config_path; use self::set::ConfigSetArgs; -use self::unset::cmd_config_unset; +use self::set::cmd_config_set; use self::unset::ConfigUnsetArgs; +use self::unset::cmd_config_unset; use crate::cli_util::CommandHelper; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::config::ConfigEnv; use crate::ui::Ui; diff --git a/cli/src/commands/config/path.rs b/cli/src/commands/config/path.rs index 0df77e53a..df5bd40ce 100644 --- a/cli/src/commands/config/path.rs +++ b/cli/src/commands/config/path.rs @@ -19,8 +19,8 @@ use tracing::instrument; use super::ConfigLevelArgs; use crate::cli_util::CommandHelper; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::ui::Ui; /// Print the paths to the config files diff --git a/cli/src/commands/config/set.rs b/cli/src/commands/config/set.rs index 4ad995bcc..f00ff5133 100644 --- a/cli/src/commands/config/set.rs +++ b/cli/src/commands/config/set.rs @@ -24,8 +24,8 @@ use tracing::instrument; use super::ConfigLevelArgs; use crate::cli_util::CommandHelper; use crate::cli_util::WorkspaceCommandHelper; -use crate::command_error::user_error_with_message; use crate::command_error::CommandError; +use crate::command_error::user_error_with_message; use crate::complete; use crate::config::parse_value_or_bare_string; use crate::ui::Ui; diff --git a/cli/src/commands/config/unset.rs b/cli/src/commands/config/unset.rs index 77dc71a29..0edbcc235 100644 --- a/cli/src/commands/config/unset.rs +++ b/cli/src/commands/config/unset.rs @@ -18,9 +18,9 @@ use tracing::instrument; use super::ConfigLevelArgs; use crate::cli_util::CommandHelper; +use crate::command_error::CommandError; use crate::command_error::user_error; use crate::command_error::user_error_with_message; -use crate::command_error::CommandError; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/debug/fileset.rs b/cli/src/commands/debug/fileset.rs index de4154375..a44690b79 100644 --- a/cli/src/commands/debug/fileset.rs +++ b/cli/src/commands/debug/fileset.rs @@ -19,8 +19,8 @@ use jj_lib::fileset; use jj_lib::fileset::FilesetDiagnostics; use crate::cli_util::CommandHelper; -use crate::command_error::print_parse_diagnostics; use crate::command_error::CommandError; +use crate::command_error::print_parse_diagnostics; use crate::ui::Ui; /// Parse fileset expression diff --git a/cli/src/commands/debug/index.rs b/cli/src/commands/debug/index.rs index 8e6b4e4f5..657a0afa2 100644 --- a/cli/src/commands/debug/index.rs +++ b/cli/src/commands/debug/index.rs @@ -18,9 +18,9 @@ use std::io::Write as _; use jj_lib::default_index::DefaultReadonlyIndex; use crate::cli_util::CommandHelper; +use crate::command_error::CommandError; use crate::command_error::internal_error; use crate::command_error::user_error; -use crate::command_error::CommandError; use crate::ui::Ui; /// Show commit index stats diff --git a/cli/src/commands/debug/init_simple.rs b/cli/src/commands/debug/init_simple.rs index 2aadd0005..a2a8fe967 100644 --- a/cli/src/commands/debug/init_simple.rs +++ b/cli/src/commands/debug/init_simple.rs @@ -19,9 +19,9 @@ use jj_lib::workspace::Workspace; use tracing::instrument; use crate::cli_util::CommandHelper; +use crate::command_error::CommandError; use crate::command_error::cli_error; use crate::command_error::user_error_with_message; -use crate::command_error::CommandError; use crate::ui::Ui; /// Create a new repo in the given directory using the proof-of-concept simple diff --git a/cli/src/commands/debug/mod.rs b/cli/src/commands/debug/mod.rs index bc58af240..6d4243126 100644 --- a/cli/src/commands/debug/mod.rs +++ b/cli/src/commands/debug/mod.rs @@ -32,35 +32,35 @@ use std::fmt::Debug; use clap::Subcommand; use jj_lib::local_working_copy::LocalWorkingCopy; -use self::copy_detection::cmd_debug_copy_detection; use self::copy_detection::CopyDetectionArgs; -use self::fileset::cmd_debug_fileset; +use self::copy_detection::cmd_debug_copy_detection; use self::fileset::DebugFilesetArgs; -use self::index::cmd_debug_index; +use self::fileset::cmd_debug_fileset; use self::index::DebugIndexArgs; -use self::init_simple::cmd_debug_init_simple; +use self::index::cmd_debug_index; use self::init_simple::DebugInitSimpleArgs; -use self::local_working_copy::cmd_debug_local_working_copy; +use self::init_simple::cmd_debug_init_simple; use self::local_working_copy::DebugLocalWorkingCopyArgs; -use self::operation::cmd_debug_operation; +use self::local_working_copy::cmd_debug_local_working_copy; use self::operation::DebugOperationArgs; -use self::reindex::cmd_debug_reindex; +use self::operation::cmd_debug_operation; use self::reindex::DebugReindexArgs; -use self::revset::cmd_debug_revset; +use self::reindex::cmd_debug_reindex; use self::revset::DebugRevsetArgs; -use self::snapshot::cmd_debug_snapshot; +use self::revset::cmd_debug_revset; use self::snapshot::DebugSnapshotArgs; -use self::template::cmd_debug_template; +use self::snapshot::cmd_debug_snapshot; use self::template::DebugTemplateArgs; -use self::tree::cmd_debug_tree; +use self::template::cmd_debug_template; use self::tree::DebugTreeArgs; -use self::watchman::cmd_debug_watchman; +use self::tree::cmd_debug_tree; use self::watchman::DebugWatchmanCommand; -use self::working_copy::cmd_debug_working_copy; +use self::watchman::cmd_debug_watchman; use self::working_copy::DebugWorkingCopyArgs; +use self::working_copy::cmd_debug_working_copy; use crate::cli_util::CommandHelper; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::ui::Ui; /// Low-level commands not intended for users diff --git a/cli/src/commands/debug/reindex.rs b/cli/src/commands/debug/reindex.rs index 56f9ab5e7..59d9413da 100644 --- a/cli/src/commands/debug/reindex.rs +++ b/cli/src/commands/debug/reindex.rs @@ -18,9 +18,9 @@ use std::io::Write as _; use jj_lib::default_index::DefaultIndexStore; use crate::cli_util::CommandHelper; +use crate::command_error::CommandError; use crate::command_error::internal_error; use crate::command_error::user_error; -use crate::command_error::CommandError; use crate::ui::Ui; /// Rebuild commit index diff --git a/cli/src/commands/debug/revset.rs b/cli/src/commands/debug/revset.rs index 54282b8fe..7bba643eb 100644 --- a/cli/src/commands/debug/revset.rs +++ b/cli/src/commands/debug/revset.rs @@ -20,8 +20,8 @@ use jj_lib::revset; use jj_lib::revset::RevsetDiagnostics; use crate::cli_util::CommandHelper; -use crate::command_error::print_parse_diagnostics; use crate::command_error::CommandError; +use crate::command_error::print_parse_diagnostics; use crate::revset_util; use crate::ui::Ui; diff --git a/cli/src/commands/debug/tree.rs b/cli/src/commands/debug/tree.rs index 530fd0f83..b7b45eab8 100644 --- a/cli/src/commands/debug/tree.rs +++ b/cli/src/commands/debug/tree.rs @@ -22,8 +22,8 @@ use jj_lib::repo_path::RepoPathBuf; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::ui::Ui; /// List the recursive entries of a tree. diff --git a/cli/src/commands/debug/watchman.rs b/cli/src/commands/debug/watchman.rs index 8eb7d9396..67ee750a5 100644 --- a/cli/src/commands/debug/watchman.rs +++ b/cli/src/commands/debug/watchman.rs @@ -27,8 +27,8 @@ use jj_lib::fsmonitor::WatchmanConfig; use jj_lib::local_working_copy::LocalWorkingCopy; use crate::cli_util::CommandHelper; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::ui::Ui; #[derive(Subcommand, Clone, Debug)] @@ -86,7 +86,7 @@ pub fn cmd_debug_watchman( other_fsmonitor => { return Err(user_error(format!( r"This command does not support the currently enabled filesystem monitor: {other_fsmonitor:?}." - ))) + ))); } }; let wc = check_local_disk_wc(workspace_command.working_copy().as_any())?; diff --git a/cli/src/commands/describe.rs b/cli/src/commands/describe.rs index c959f3ffa..cccc348ee 100644 --- a/cli/src/commands/describe.rs +++ b/cli/src/commands/describe.rs @@ -26,16 +26,16 @@ use tracing::instrument; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::complete; +use crate::description_util::ParsedBulkEditMessage; use crate::description_util::add_trailers_with_template; use crate::description_util::description_template; use crate::description_util::edit_description; use crate::description_util::edit_multiple_descriptions; use crate::description_util::join_message_paragraphs; use crate::description_util::parse_trailers_template; -use crate::description_util::ParsedBulkEditMessage; use crate::text_util::parse_author; use crate::ui::Ui; diff --git a/cli/src/commands/diff.rs b/cli/src/commands/diff.rs index db5a62891..dee7a9a32 100644 --- a/cli/src/commands/diff.rs +++ b/cli/src/commands/diff.rs @@ -21,16 +21,16 @@ use jj_lib::rewrite::merge_commit_trees; use pollster::FutureExt as _; use tracing::instrument; -use crate::cli_util::print_unmatched_explicit_paths; -use crate::cli_util::short_commit_hash; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; -use crate::command_error::user_error_with_hint; +use crate::cli_util::print_unmatched_explicit_paths; +use crate::cli_util::short_commit_hash; use crate::command_error::CommandError; +use crate::command_error::user_error_with_hint; use crate::complete; +use crate::diff_util::DiffFormatArgs; use crate::diff_util::get_copy_records; use crate::diff_util::show_templated; -use crate::diff_util::DiffFormatArgs; use crate::ui::Ui; /// Compare file contents between two revisions diff --git a/cli/src/commands/diffedit.rs b/cli/src/commands/diffedit.rs index ef9ad616f..ef9c54168 100644 --- a/cli/src/commands/diffedit.rs +++ b/cli/src/commands/diffedit.rs @@ -22,9 +22,9 @@ use jj_lib::rewrite::merge_commit_trees; use pollster::FutureExt as _; use tracing::instrument; -use crate::cli_util::print_unmatched_explicit_paths; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; +use crate::cli_util::print_unmatched_explicit_paths; use crate::command_error::CommandError; use crate::complete; use crate::ui::Ui; @@ -116,8 +116,10 @@ pub(crate) fn cmd_diffedit( if args.from.is_some() || args.to.is_some() { target_commit = workspace_command .resolve_single_rev(ui, args.to.as_ref().unwrap_or(&RevisionArg::AT))?; - base_commits = vec![workspace_command - .resolve_single_rev(ui, args.from.as_ref().unwrap_or(&RevisionArg::AT))?]; + base_commits = vec![ + workspace_command + .resolve_single_rev(ui, args.from.as_ref().unwrap_or(&RevisionArg::AT))?, + ]; diff_description = format!( "The diff initially shows the commit's changes relative to:\n{}", workspace_command.format_commit_summary(&base_commits[0]) diff --git a/cli/src/commands/duplicate.rs b/cli/src/commands/duplicate.rs index 6defaec10..2bc023c37 100644 --- a/cli/src/commands/duplicate.rs +++ b/cli/src/commands/duplicate.rs @@ -20,17 +20,17 @@ use itertools::Itertools as _; use jj_lib::backend::BackendResult; use jj_lib::backend::CommitId; use jj_lib::repo::Repo as _; +use jj_lib::rewrite::DuplicateCommitsStats; use jj_lib::rewrite::duplicate_commits; use jj_lib::rewrite::duplicate_commits_onto_parents; -use jj_lib::rewrite::DuplicateCommitsStats; use tracing::instrument; -use crate::cli_util::compute_commit_location; -use crate::cli_util::short_commit_hash; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; -use crate::command_error::user_error; +use crate::cli_util::compute_commit_location; +use crate::cli_util::short_commit_hash; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/evolog.rs b/cli/src/commands/evolog.rs index ec424fc4c..e6957627c 100644 --- a/cli/src/commands/evolog.rs +++ b/cli/src/commands/evolog.rs @@ -19,21 +19,21 @@ use clap_complete::ArgValueCompleter; use itertools::Itertools as _; use jj_lib::commit::Commit; use jj_lib::evolution::walk_predecessors; -use jj_lib::graph::reverse_graph; use jj_lib::graph::GraphEdge; use jj_lib::graph::TopoGroupedGraphIterator; +use jj_lib::graph::reverse_graph; use jj_lib::matchers::EverythingMatcher; use tracing::instrument; -use crate::cli_util::format_template; use crate::cli_util::CommandHelper; use crate::cli_util::LogContentFormat; use crate::cli_util::RevisionArg; +use crate::cli_util::format_template; use crate::command_error::CommandError; use crate::complete; use crate::diff_util::DiffFormatArgs; -use crate::graphlog::get_graphlog; use crate::graphlog::GraphStyle; +use crate::graphlog::get_graphlog; use crate::templater::TemplateRenderer; use crate::ui::Ui; diff --git a/cli/src/commands/file/annotate.rs b/cli/src/commands/file/annotate.rs index cc8d3fff4..59a218568 100644 --- a/cli/src/commands/file/annotate.rs +++ b/cli/src/commands/file/annotate.rs @@ -23,8 +23,8 @@ use tracing::instrument; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::commit_templater::AnnotationLine; use crate::complete; use crate::templater::TemplateRenderer; diff --git a/cli/src/commands/file/chmod.rs b/cli/src/commands/file/chmod.rs index 0e5d2063d..ee3a6621a 100644 --- a/cli/src/commands/file/chmod.rs +++ b/cli/src/commands/file/chmod.rs @@ -18,11 +18,11 @@ use jj_lib::merged_tree::MergedTreeBuilder; use jj_lib::object_id::ObjectId as _; use tracing::instrument; -use crate::cli_util::print_unmatched_explicit_paths; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; -use crate::command_error::user_error; +use crate::cli_util::print_unmatched_explicit_paths; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/file/show.rs b/cli/src/commands/file/show.rs index 305b481da..0d3df0eb7 100644 --- a/cli/src/commands/file/show.rs +++ b/cli/src/commands/file/show.rs @@ -16,9 +16,9 @@ use std::io::Write as _; use clap_complete::ArgValueCompleter; use jj_lib::backend::BackendResult; +use jj_lib::conflicts::MaterializedTreeValue; use jj_lib::conflicts::materialize_merge_result; use jj_lib::conflicts::materialize_tree_value; -use jj_lib::conflicts::MaterializedTreeValue; use jj_lib::file_util::copy_async_to_sync; use jj_lib::fileset::FilePattern; use jj_lib::fileset::FilesetExpression; @@ -28,12 +28,12 @@ use jj_lib::repo_path::RepoPath; use pollster::FutureExt as _; use tracing::instrument; -use crate::cli_util::print_unmatched_explicit_paths; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; use crate::cli_util::WorkspaceCommandHelper; -use crate::command_error::user_error; +use crate::cli_util::print_unmatched_explicit_paths; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/file/track.rs b/cli/src/commands/file/track.rs index b77cb6f1d..3c204053f 100644 --- a/cli/src/commands/file/track.rs +++ b/cli/src/commands/file/track.rs @@ -22,8 +22,8 @@ use jj_lib::working_copy::SnapshotStats; use jj_lib::working_copy::UntrackedReason; use tracing::instrument; -use crate::cli_util::print_untracked_files; use crate::cli_util::CommandHelper; +use crate::cli_util::print_untracked_files; use crate::command_error::CommandError; use crate::ui::Ui; diff --git a/cli/src/commands/file/untrack.rs b/cli/src/commands/file/untrack.rs index 0c5f57373..d9df50c66 100644 --- a/cli/src/commands/file/untrack.rs +++ b/cli/src/commands/file/untrack.rs @@ -21,10 +21,10 @@ use jj_lib::merged_tree::MergedTreeBuilder; use jj_lib::repo::Repo as _; use tracing::instrument; -use crate::cli_util::print_snapshot_stats; use crate::cli_util::CommandHelper; -use crate::command_error::user_error_with_hint; +use crate::cli_util::print_snapshot_stats; use crate::command_error::CommandError; +use crate::command_error::user_error_with_hint; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/fix.rs b/cli/src/commands/fix.rs index 917fcb4d8..707cdbd54 100644 --- a/cli/src/commands/fix.rs +++ b/cli/src/commands/fix.rs @@ -24,10 +24,10 @@ use jj_lib::backend::FileId; use jj_lib::fileset; use jj_lib::fileset::FilesetDiagnostics; use jj_lib::fileset::FilesetExpression; -use jj_lib::fix::fix_files; use jj_lib::fix::FileToFix; use jj_lib::fix::FixError; use jj_lib::fix::ParallelFileFixer; +use jj_lib::fix::fix_files; use jj_lib::matchers::Matcher; use jj_lib::repo_path::RepoPathUiConverter; use jj_lib::settings::UserSettings; @@ -38,9 +38,9 @@ use tracing::instrument; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; +use crate::command_error::CommandError; use crate::command_error::config_error; use crate::command_error::print_parse_diagnostics; -use crate::command_error::CommandError; use crate::complete; use crate::config::CommandNameAndArgs; use crate::ui::Ui; diff --git a/cli/src/commands/git/clone.rs b/cli/src/commands/git/clone.rs index 7fd296a36..65f183a65 100644 --- a/cli/src/commands/git/clone.rs +++ b/cli/src/commands/git/clone.rs @@ -30,10 +30,10 @@ use jj_lib::workspace::Workspace; use super::write_repository_level_trunk_alias; use crate::cli_util::CommandHelper; use crate::cli_util::WorkspaceCommandHelper; +use crate::command_error::CommandError; use crate::command_error::cli_error; use crate::command_error::user_error; use crate::command_error::user_error_with_message; -use crate::command_error::CommandError; use crate::commands::git::maybe_add_gitignore; use crate::git_util::absolute_git_url; use crate::git_util::print_git_import_stats; diff --git a/cli/src/commands/git/fetch.rs b/cli/src/commands/git/fetch.rs index c1a23557d..883fe91a1 100644 --- a/cli/src/commands/git/fetch.rs +++ b/cli/src/commands/git/fetch.rs @@ -26,9 +26,9 @@ use jj_lib::str_util::StringPattern; use crate::cli_util::CommandHelper; use crate::cli_util::WorkspaceCommandHelper; use crate::cli_util::WorkspaceCommandTransaction; +use crate::command_error::CommandError; use crate::command_error::config_error; use crate::command_error::user_error; -use crate::command_error::CommandError; use crate::commands::git::get_single_remote; use crate::complete; use crate::git_util::print_git_import_stats; diff --git a/cli/src/commands/git/init.rs b/cli/src/commands/git/init.rs index 52c7d8b51..3357a3222 100644 --- a/cli/src/commands/git/init.rs +++ b/cli/src/commands/git/init.rs @@ -23,22 +23,22 @@ use indoc::writedoc; use itertools::Itertools as _; use jj_lib::file_util; use jj_lib::git; -use jj_lib::git::parse_git_ref; use jj_lib::git::GitRefKind; +use jj_lib::git::parse_git_ref; use jj_lib::repo::ReadonlyRepo; use jj_lib::repo::Repo as _; use jj_lib::view::View; use jj_lib::workspace::Workspace; use super::write_repository_level_trunk_alias; -use crate::cli_util::start_repo_transaction; use crate::cli_util::CommandHelper; use crate::cli_util::WorkspaceCommandHelper; +use crate::cli_util::start_repo_transaction; +use crate::command_error::CommandError; use crate::command_error::cli_error; use crate::command_error::internal_error; use crate::command_error::user_error_with_hint; use crate::command_error::user_error_with_message; -use crate::command_error::CommandError; use crate::commands::git::maybe_add_gitignore; use crate::git_util::is_colocated_git_workspace; use crate::git_util::print_git_export_stats; diff --git a/cli/src/commands/git/mod.rs b/cli/src/commands/git/mod.rs index 37dc92325..ba1fd7b41 100644 --- a/cli/src/commands/git/mod.rs +++ b/cli/src/commands/git/mod.rs @@ -32,26 +32,26 @@ use jj_lib::ref_name::RemoteNameBuf; use jj_lib::ref_name::RemoteRefSymbol; use jj_lib::store::Store; -use self::clone::cmd_git_clone; use self::clone::GitCloneArgs; -use self::export::cmd_git_export; +use self::clone::cmd_git_clone; use self::export::GitExportArgs; -use self::fetch::cmd_git_fetch; +use self::export::cmd_git_export; use self::fetch::GitFetchArgs; -use self::import::cmd_git_import; +use self::fetch::cmd_git_fetch; use self::import::GitImportArgs; -use self::init::cmd_git_init; +use self::import::cmd_git_import; use self::init::GitInitArgs; -use self::push::cmd_git_push; +use self::init::cmd_git_init; use self::push::GitPushArgs; -use self::remote::cmd_git_remote; +use self::push::cmd_git_push; use self::remote::RemoteCommand; -use self::root::cmd_git_root; +use self::remote::cmd_git_remote; use self::root::GitRootArgs; +use self::root::cmd_git_root; use crate::cli_util::CommandHelper; use crate::cli_util::WorkspaceCommandHelper; -use crate::command_error::user_error_with_message; use crate::command_error::CommandError; +use crate::command_error::user_error_with_message; use crate::ui::Ui; /// Commands for working with Git remotes and the underlying Git repo diff --git a/cli/src/commands/git/push.rs b/cli/src/commands/git/push.rs index 88403257e..18579fb1d 100644 --- a/cli/src/commands/git/push.rs +++ b/cli/src/commands/git/push.rs @@ -37,10 +37,10 @@ use jj_lib::ref_name::RefNameBuf; use jj_lib::ref_name::RemoteName; use jj_lib::ref_name::RemoteNameBuf; use jj_lib::ref_name::RemoteRefSymbol; -use jj_lib::refs::classify_bookmark_push_action; use jj_lib::refs::BookmarkPushAction; use jj_lib::refs::BookmarkPushUpdate; use jj_lib::refs::LocalAndRemoteRef; +use jj_lib::refs::classify_bookmark_push_action; use jj_lib::repo::Repo; use jj_lib::revset::RevsetExpression; use jj_lib::settings::UserSettings; @@ -48,18 +48,18 @@ use jj_lib::signing::SignBehavior; use jj_lib::str_util::StringPattern; use jj_lib::view::View; -use crate::cli_util::has_tracked_remote_bookmarks; -use crate::cli_util::short_commit_hash; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; use crate::cli_util::WorkspaceCommandHelper; use crate::cli_util::WorkspaceCommandTransaction; +use crate::cli_util::has_tracked_remote_bookmarks; +use crate::cli_util::short_commit_hash; +use crate::command_error::CommandError; use crate::command_error::cli_error; use crate::command_error::cli_error_with_message; use crate::command_error::user_error; use crate::command_error::user_error_with_hint; use crate::command_error::user_error_with_message; -use crate::command_error::CommandError; use crate::commands::git::get_single_remote; use crate::complete; use crate::formatter::Formatter; diff --git a/cli/src/commands/git/remote/list.rs b/cli/src/commands/git/remote/list.rs index 73c9818b5..6e1fa287c 100644 --- a/cli/src/commands/git/remote/list.rs +++ b/cli/src/commands/git/remote/list.rs @@ -18,8 +18,8 @@ use jj_lib::git; use jj_lib::repo::Repo as _; use crate::cli_util::CommandHelper; -use crate::command_error::user_error_with_message; use crate::command_error::CommandError; +use crate::command_error::user_error_with_message; use crate::ui::Ui; /// List Git remotes @@ -40,7 +40,7 @@ pub fn cmd_git_remote_list( return Err(user_error_with_message( format!("Failed to load configured remote {remote_name}"), err, - )) + )); } None => continue, // ignore empty [remote ""] section }; diff --git a/cli/src/commands/git/remote/mod.rs b/cli/src/commands/git/remote/mod.rs index 9f2847f42..186818b4f 100644 --- a/cli/src/commands/git/remote/mod.rs +++ b/cli/src/commands/git/remote/mod.rs @@ -20,16 +20,16 @@ mod set_url; use clap::Subcommand; -use self::add::cmd_git_remote_add; use self::add::GitRemoteAddArgs; -use self::list::cmd_git_remote_list; +use self::add::cmd_git_remote_add; use self::list::GitRemoteListArgs; -use self::remove::cmd_git_remote_remove; +use self::list::cmd_git_remote_list; use self::remove::GitRemoteRemoveArgs; -use self::rename::cmd_git_remote_rename; +use self::remove::cmd_git_remote_remove; use self::rename::GitRemoteRenameArgs; -use self::set_url::cmd_git_remote_set_url; +use self::rename::cmd_git_remote_rename; use self::set_url::GitRemoteSetUrlArgs; +use self::set_url::cmd_git_remote_set_url; use crate::cli_util::CommandHelper; use crate::command_error::CommandError; use crate::ui::Ui; diff --git a/cli/src/commands/git/root.rs b/cli/src/commands/git/root.rs index 748aa6c10..7666ddafc 100644 --- a/cli/src/commands/git/root.rs +++ b/cli/src/commands/git/root.rs @@ -19,8 +19,8 @@ use jj_lib::repo::Repo as _; use tracing::instrument; use crate::cli_util::CommandHelper; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::ui::Ui; /// Show the underlying Git directory of a repository using the Git backend diff --git a/cli/src/commands/log.rs b/cli/src/commands/log.rs index 2ce95df16..ccf4a195c 100644 --- a/cli/src/commands/log.rs +++ b/cli/src/commands/log.rs @@ -17,10 +17,10 @@ use clap_complete::ArgValueCompleter; use itertools::Itertools as _; use jj_lib::backend::CommitId; use jj_lib::commit::Commit; -use jj_lib::graph::reverse_graph; use jj_lib::graph::GraphEdge; use jj_lib::graph::GraphEdgeType; use jj_lib::graph::TopoGroupedGraphIterator; +use jj_lib::graph::reverse_graph; use jj_lib::repo::Repo as _; use jj_lib::revset::RevsetEvaluationError; use jj_lib::revset::RevsetExpression; @@ -28,15 +28,15 @@ use jj_lib::revset::RevsetFilterPredicate; use jj_lib::revset::RevsetIteratorExt as _; use tracing::instrument; -use crate::cli_util::format_template; use crate::cli_util::CommandHelper; use crate::cli_util::LogContentFormat; use crate::cli_util::RevisionArg; +use crate::cli_util::format_template; use crate::command_error::CommandError; use crate::complete; use crate::diff_util::DiffFormatArgs; -use crate::graphlog::get_graphlog; use crate::graphlog::GraphStyle; +use crate::graphlog::get_graphlog; use crate::templater::TemplateRenderer; use crate::ui::Ui; diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index fa4dd5fdb..1d91643af 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -60,11 +60,11 @@ mod workspace; use std::fmt::Debug; -use clap::builder::styling::AnsiColor; -use clap::builder::Styles; use clap::CommandFactory as _; use clap::FromArgMatches as _; use clap::Subcommand as _; +use clap::builder::Styles; +use clap::builder::styling::AnsiColor; use clap_complete::engine::SubcommandCandidates; use tracing::instrument; diff --git a/cli/src/commands/new.rs b/cli/src/commands/new.rs index 6169f22f8..76dd3e11a 100644 --- a/cli/src/commands/new.rs +++ b/cli/src/commands/new.rs @@ -24,9 +24,9 @@ use jj_lib::rewrite::rebase_commit; use pollster::FutureExt as _; use tracing::instrument; -use crate::cli_util::compute_commit_location; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; +use crate::cli_util::compute_commit_location; use crate::command_error::CommandError; use crate::complete; use crate::description_util::add_trailers; diff --git a/cli/src/commands/next.rs b/cli/src/commands/next.rs index 1b7367259..b1141a6f0 100644 --- a/cli/src/commands/next.rs +++ b/cli/src/commands/next.rs @@ -14,9 +14,9 @@ use crate::cli_util::CommandHelper; use crate::command_error::CommandError; -use crate::movement_util::move_to_commit; use crate::movement_util::Direction; use crate::movement_util::MovementArgs; +use crate::movement_util::move_to_commit; use crate::ui::Ui; /// Move the working-copy commit to the child revision diff --git a/cli/src/commands/operation/abandon.rs b/cli/src/commands/operation/abandon.rs index e42bf6f26..238da7712 100644 --- a/cli/src/commands/operation/abandon.rs +++ b/cli/src/commands/operation/abandon.rs @@ -20,11 +20,11 @@ use clap_complete::ArgValueCandidates; use itertools::Itertools as _; use jj_lib::op_walk; -use crate::cli_util::short_operation_hash; use crate::cli_util::CommandHelper; +use crate::cli_util::short_operation_hash; +use crate::command_error::CommandError; use crate::command_error::cli_error; use crate::command_error::user_error; -use crate::command_error::CommandError; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/operation/diff.rs b/cli/src/commands/operation/diff.rs index 31f9c0ece..dac27d8d8 100644 --- a/cli/src/commands/operation/diff.rs +++ b/cli/src/commands/operation/diff.rs @@ -40,12 +40,12 @@ use crate::cli_util::CommandHelper; use crate::cli_util::LogContentFormat; use crate::command_error::CommandError; use crate::complete; -use crate::diff_util::diff_formats_for_log; use crate::diff_util::DiffFormatArgs; use crate::diff_util::DiffRenderer; +use crate::diff_util::diff_formats_for_log; use crate::formatter::Formatter; -use crate::graphlog::get_graphlog; use crate::graphlog::GraphStyle; +use crate::graphlog::get_graphlog; use crate::templater::TemplateRenderer; use crate::ui::Ui; diff --git a/cli/src/commands/operation/log.rs b/cli/src/commands/operation/log.rs index 5d566fc49..9b50d9df7 100644 --- a/cli/src/commands/operation/log.rs +++ b/cli/src/commands/operation/log.rs @@ -16,26 +16,26 @@ use std::slice; use clap_complete::ArgValueCandidates; use itertools::Itertools as _; -use jj_lib::graph::reverse_graph; use jj_lib::graph::GraphEdge; +use jj_lib::graph::reverse_graph; use jj_lib::op_store::OpStoreError; use jj_lib::op_walk; use jj_lib::operation::Operation; use jj_lib::repo::RepoLoader; use super::diff::show_op_diff; -use crate::cli_util::format_template; use crate::cli_util::CommandHelper; use crate::cli_util::LogContentFormat; use crate::cli_util::WorkspaceCommandEnvironment; +use crate::cli_util::format_template; use crate::command_error::CommandError; use crate::complete; -use crate::diff_util::diff_formats_for_log; use crate::diff_util::DiffFormatArgs; use crate::diff_util::DiffRenderer; +use crate::diff_util::diff_formats_for_log; use crate::formatter::Formatter; -use crate::graphlog::get_graphlog; use crate::graphlog::GraphStyle; +use crate::graphlog::get_graphlog; use crate::operation_templater::OperationTemplateLanguage; use crate::templater::TemplateRenderer; use crate::ui::Ui; diff --git a/cli/src/commands/operation/mod.rs b/cli/src/commands/operation/mod.rs index c9025b2a2..6abdf596b 100644 --- a/cli/src/commands/operation/mod.rs +++ b/cli/src/commands/operation/mod.rs @@ -19,19 +19,19 @@ mod restore; mod show; pub mod undo; -use abandon::cmd_op_abandon; use abandon::OperationAbandonArgs; +use abandon::cmd_op_abandon; use clap::Subcommand; -use diff::cmd_op_diff; use diff::OperationDiffArgs; -use log::cmd_op_log; +use diff::cmd_op_diff; use log::OperationLogArgs; -use restore::cmd_op_restore; +use log::cmd_op_log; use restore::OperationRestoreArgs; -use show::cmd_op_show; +use restore::cmd_op_restore; use show::OperationShowArgs; -use undo::cmd_op_undo; +use show::cmd_op_show; use undo::OperationUndoArgs; +use undo::cmd_op_undo; use crate::cli_util::CommandHelper; use crate::command_error::CommandError; diff --git a/cli/src/commands/operation/restore.rs b/cli/src/commands/operation/restore.rs index 067ae4401..872cba538 100644 --- a/cli/src/commands/operation/restore.rs +++ b/cli/src/commands/operation/restore.rs @@ -15,9 +15,9 @@ use clap_complete::ArgValueCandidates; use jj_lib::object_id::ObjectId as _; -use super::view_with_desired_portions_restored; -use super::UndoWhatToRestore; use super::DEFAULT_UNDO_WHAT; +use super::UndoWhatToRestore; +use super::view_with_desired_portions_restored; use crate::cli_util::CommandHelper; use crate::command_error::CommandError; use crate::complete; diff --git a/cli/src/commands/operation/show.rs b/cli/src/commands/operation/show.rs index 0317228b5..c9a7d195b 100644 --- a/cli/src/commands/operation/show.rs +++ b/cli/src/commands/operation/show.rs @@ -21,9 +21,9 @@ use crate::cli_util::CommandHelper; use crate::cli_util::LogContentFormat; use crate::command_error::CommandError; use crate::complete; -use crate::diff_util::diff_formats_for_log; use crate::diff_util::DiffFormatArgs; use crate::diff_util::DiffRenderer; +use crate::diff_util::diff_formats_for_log; use crate::graphlog::GraphStyle; use crate::templater::TemplateRenderer; use crate::ui::Ui; diff --git a/cli/src/commands/operation/undo.rs b/cli/src/commands/operation/undo.rs index 717c9c960..32caef46e 100644 --- a/cli/src/commands/operation/undo.rs +++ b/cli/src/commands/operation/undo.rs @@ -19,12 +19,12 @@ use jj_lib::op_store::OpStoreError; use jj_lib::operation::Operation; use jj_lib::repo::Repo as _; -use super::view_with_desired_portions_restored; -use super::UndoWhatToRestore; use super::DEFAULT_UNDO_WHAT; +use super::UndoWhatToRestore; +use super::view_with_desired_portions_restored; use crate::cli_util::CommandHelper; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/prev.rs b/cli/src/commands/prev.rs index 7461d3390..235458534 100644 --- a/cli/src/commands/prev.rs +++ b/cli/src/commands/prev.rs @@ -14,9 +14,9 @@ use crate::cli_util::CommandHelper; use crate::command_error::CommandError; -use crate::movement_util::move_to_commit; use crate::movement_util::Direction; use crate::movement_util::MovementArgs; +use crate::movement_util::move_to_commit; use crate::ui::Ui; /// Change the working copy revision relative to the parent revision /// diff --git a/cli/src/commands/rebase.rs b/cli/src/commands/rebase.rs index 20a549234..d778b1f0b 100644 --- a/cli/src/commands/rebase.rs +++ b/cli/src/commands/rebase.rs @@ -24,24 +24,24 @@ use jj_lib::object_id::ObjectId as _; use jj_lib::repo::ReadonlyRepo; use jj_lib::repo::Repo as _; use jj_lib::revset::RevsetExpression; -use jj_lib::rewrite::compute_move_commits; -use jj_lib::rewrite::find_duplicate_divergent_commits; use jj_lib::rewrite::EmptyBehavior; use jj_lib::rewrite::MoveCommitsLocation; use jj_lib::rewrite::MoveCommitsStats; use jj_lib::rewrite::MoveCommitsTarget; use jj_lib::rewrite::RebaseOptions; use jj_lib::rewrite::RewriteRefsOptions; +use jj_lib::rewrite::compute_move_commits; +use jj_lib::rewrite::find_duplicate_divergent_commits; use tracing::instrument; -use crate::cli_util::compute_commit_location; -use crate::cli_util::print_updated_commits; -use crate::cli_util::short_commit_hash; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; use crate::cli_util::WorkspaceCommandHelper; -use crate::command_error::user_error; +use crate::cli_util::compute_commit_location; +use crate::cli_util::print_updated_commits; +use crate::cli_util::short_commit_hash; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::complete; use crate::ui::Ui; @@ -495,10 +495,12 @@ fn plan_rebase_branch( rebase_destination: &RebaseDestinationArgs, ) -> Result { let branch_commit_ids: Vec<_> = if branch.is_empty() { - vec![workspace_command - .resolve_single_rev(ui, &RevisionArg::AT)? - .id() - .clone()] + vec![ + workspace_command + .resolve_single_rev(ui, &RevisionArg::AT)? + .id() + .clone(), + ] } else { workspace_command .resolve_some_revsets_default_single(ui, branch)? diff --git a/cli/src/commands/resolve.rs b/cli/src/commands/resolve.rs index c0bf9f899..eb6f7b81c 100644 --- a/cli/src/commands/resolve.rs +++ b/cli/src/commands/resolve.rs @@ -18,11 +18,11 @@ use itertools::Itertools as _; use jj_lib::object_id::ObjectId as _; use tracing::instrument; -use crate::cli_util::print_conflicted_paths; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; -use crate::command_error::cli_error; +use crate::cli_util::print_conflicted_paths; use crate::command_error::CommandError; +use crate::command_error::cli_error; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/restore.rs b/cli/src/commands/restore.rs index cec154854..d88e7c44f 100644 --- a/cli/src/commands/restore.rs +++ b/cli/src/commands/restore.rs @@ -23,8 +23,8 @@ use tracing::instrument; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/revert.rs b/cli/src/commands/revert.rs index 35ea44e96..2fdf35442 100644 --- a/cli/src/commands/revert.rs +++ b/cli/src/commands/revert.rs @@ -26,10 +26,10 @@ use jj_lib::rewrite::merge_commit_trees; use pollster::FutureExt as _; use tracing::instrument; -use crate::cli_util::compute_commit_location; -use crate::cli_util::print_updated_commits; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; +use crate::cli_util::compute_commit_location; +use crate::cli_util::print_updated_commits; use crate::command_error::CommandError; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/root.rs b/cli/src/commands/root.rs index 2896d8c04..1d23536b4 100644 --- a/cli/src/commands/root.rs +++ b/cli/src/commands/root.rs @@ -18,8 +18,8 @@ use jj_lib::file_util; use tracing::instrument; use crate::cli_util::CommandHelper; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::ui::Ui; /// Show the current workspace root directory (shortcut for `jj workspace root`) diff --git a/cli/src/commands/run.rs b/cli/src/commands/run.rs index 67d96adec..69b6138bc 100644 --- a/cli/src/commands/run.rs +++ b/cli/src/commands/run.rs @@ -18,8 +18,8 @@ use itertools::Itertools as _; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::ui::Ui; /// (**Stub**, does not work yet) Run a command across a set of revisions. diff --git a/cli/src/commands/sign.rs b/cli/src/commands/sign.rs index a0836818d..1c9835b05 100644 --- a/cli/src/commands/sign.rs +++ b/cli/src/commands/sign.rs @@ -20,11 +20,11 @@ use jj_lib::commit::CommitIteratorExt as _; use jj_lib::repo::Repo as _; use jj_lib::signing::SignBehavior; -use crate::cli_util::print_updated_commits; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; -use crate::command_error::user_error_with_hint; +use crate::cli_util::print_updated_commits; use crate::command_error::CommandError; +use crate::command_error::user_error_with_hint; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/sparse/edit.rs b/cli/src/commands/sparse/edit.rs index 12ab2df8b..b362adc2e 100644 --- a/cli/src/commands/sparse/edit.rs +++ b/cli/src/commands/sparse/edit.rs @@ -21,9 +21,9 @@ use tracing::instrument; use super::update_sparse_patterns_with; use crate::cli_util::CommandHelper; +use crate::command_error::CommandError; use crate::command_error::internal_error; use crate::command_error::user_error_with_message; -use crate::command_error::CommandError; use crate::description_util::TextEditor; use crate::ui::Ui; diff --git a/cli/src/commands/sparse/mod.rs b/cli/src/commands/sparse/mod.rs index 4032b118c..556cd4dd4 100644 --- a/cli/src/commands/sparse/mod.rs +++ b/cli/src/commands/sparse/mod.rs @@ -21,19 +21,19 @@ use clap::Subcommand; use jj_lib::repo_path::RepoPathBuf; use tracing::instrument; -use self::edit::cmd_sparse_edit; use self::edit::SparseEditArgs; -use self::list::cmd_sparse_list; +use self::edit::cmd_sparse_edit; use self::list::SparseListArgs; -use self::reset::cmd_sparse_reset; +use self::list::cmd_sparse_list; use self::reset::SparseResetArgs; -use self::set::cmd_sparse_set; +use self::reset::cmd_sparse_reset; use self::set::SparseSetArgs; -use crate::cli_util::print_checkout_stats; +use self::set::cmd_sparse_set; use crate::cli_util::CommandHelper; use crate::cli_util::WorkspaceCommandHelper; -use crate::command_error::internal_error_with_message; +use crate::cli_util::print_checkout_stats; use crate::command_error::CommandError; +use crate::command_error::internal_error_with_message; use crate::ui::Ui; /// Manage which paths from the working-copy commit are present in the working diff --git a/cli/src/commands/split.rs b/cli/src/commands/split.rs index b96b33fb8..c2d5b74e3 100644 --- a/cli/src/commands/split.rs +++ b/cli/src/commands/split.rs @@ -21,7 +21,6 @@ use jj_lib::commit::Commit; use jj_lib::matchers::Matcher; use jj_lib::object_id::ObjectId as _; use jj_lib::repo::Repo as _; -use jj_lib::rewrite::move_commits; use jj_lib::rewrite::CommitWithSelection; use jj_lib::rewrite::EmptyBehavior; use jj_lib::rewrite::MoveCommitsLocation; @@ -29,17 +28,18 @@ use jj_lib::rewrite::MoveCommitsTarget; use jj_lib::rewrite::RebaseOptions; use jj_lib::rewrite::RebasedCommit; use jj_lib::rewrite::RewriteRefsOptions; +use jj_lib::rewrite::move_commits; use pollster::FutureExt as _; use tracing::instrument; -use crate::cli_util::compute_commit_location; use crate::cli_util::CommandHelper; use crate::cli_util::DiffSelector; use crate::cli_util::RevisionArg; use crate::cli_util::WorkspaceCommandHelper; use crate::cli_util::WorkspaceCommandTransaction; -use crate::command_error::user_error_with_hint; +use crate::cli_util::compute_commit_location; use crate::command_error::CommandError; +use crate::command_error::user_error_with_hint; use crate::complete; use crate::description_util::add_trailers; use crate::description_util::description_template; diff --git a/cli/src/commands/squash.rs b/cli/src/commands/squash.rs index 62d2150a0..a59cfcffb 100644 --- a/cli/src/commands/squash.rs +++ b/cli/src/commands/squash.rs @@ -29,9 +29,9 @@ use crate::cli_util::CommandHelper; use crate::cli_util::DiffSelector; use crate::cli_util::RevisionArg; use crate::cli_util::WorkspaceCommandTransaction; +use crate::command_error::CommandError; use crate::command_error::user_error; use crate::command_error::user_error_with_hint; -use crate::command_error::CommandError; use crate::complete; use crate::description_util::add_trailers; use crate::description_util::combine_messages_for_editing; diff --git a/cli/src/commands/status.rs b/cli/src/commands/status.rs index 8493d733a..bf63d1388 100644 --- a/cli/src/commands/status.rs +++ b/cli/src/commands/status.rs @@ -23,12 +23,12 @@ use jj_lib::revset::RevsetFilterPredicate; use pollster::FutureExt as _; use tracing::instrument; +use crate::cli_util::CommandHelper; use crate::cli_util::print_conflicted_paths; use crate::cli_util::print_snapshot_stats; -use crate::cli_util::CommandHelper; use crate::command_error::CommandError; -use crate::diff_util::get_copy_records; use crate::diff_util::DiffFormat; +use crate::diff_util::get_copy_records; use crate::ui::Ui; /// Show high-level repo status [default alias: st] @@ -288,9 +288,9 @@ async fn visit_collapsed_untracked_files( #[cfg(test)] mod test { - use testutils::repo_path; use testutils::TestRepo; use testutils::TestTreeBuilder; + use testutils::repo_path; use super::*; diff --git a/cli/src/commands/unsign.rs b/cli/src/commands/unsign.rs index c3bf3a68c..dbc99c8ac 100644 --- a/cli/src/commands/unsign.rs +++ b/cli/src/commands/unsign.rs @@ -19,9 +19,9 @@ use jj_lib::commit::Commit; use jj_lib::commit::CommitIteratorExt as _; use jj_lib::signing::SignBehavior; -use crate::cli_util::print_updated_commits; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; +use crate::cli_util::print_updated_commits; use crate::command_error::CommandError; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/util/completion.rs b/cli/src/commands/util/completion.rs index 317980822..b4d96dd1c 100644 --- a/cli/src/commands/util/completion.rs +++ b/cli/src/commands/util/completion.rs @@ -75,8 +75,8 @@ enum ShellCompletion { impl ShellCompletion { fn generate(&self, cmd: &mut Command) -> Vec { - use clap_complete::generate; use clap_complete::Shell; + use clap_complete::generate; use clap_complete_nushell::Nushell; let mut buf = Vec::new(); diff --git a/cli/src/commands/util/exec.rs b/cli/src/commands/util/exec.rs index a51608826..feb694f4d 100644 --- a/cli/src/commands/util/exec.rs +++ b/cli/src/commands/util/exec.rs @@ -13,9 +13,9 @@ // limitations under the License. use crate::cli_util::CommandHelper; +use crate::command_error::CommandError; use crate::command_error::user_error; use crate::command_error::user_error_with_message; -use crate::command_error::CommandError; use crate::ui::Ui; /// Execute an external command via jj diff --git a/cli/src/commands/util/gc.rs b/cli/src/commands/util/gc.rs index 18c81f30c..4a06b0e95 100644 --- a/cli/src/commands/util/gc.rs +++ b/cli/src/commands/util/gc.rs @@ -19,8 +19,8 @@ use std::time::SystemTime; use jj_lib::repo::Repo as _; use crate::cli_util::CommandHelper; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::ui::Ui; /// Run backend-dependent garbage collection. diff --git a/cli/src/commands/util/mod.rs b/cli/src/commands/util/mod.rs index f08886118..a4d141808 100644 --- a/cli/src/commands/util/mod.rs +++ b/cli/src/commands/util/mod.rs @@ -22,18 +22,18 @@ mod markdown_help; use clap::Subcommand; use tracing::instrument; -use self::completion::cmd_util_completion; use self::completion::UtilCompletionArgs; -use self::config_schema::cmd_util_config_schema; +use self::completion::cmd_util_completion; use self::config_schema::UtilConfigSchemaArgs; -use self::exec::cmd_util_exec; +use self::config_schema::cmd_util_config_schema; use self::exec::UtilExecArgs; -use self::gc::cmd_util_gc; +use self::exec::cmd_util_exec; use self::gc::UtilGcArgs; -use self::install_man_pages::cmd_util_install_man_pages; +use self::gc::cmd_util_gc; use self::install_man_pages::UtilInstallManPagesArgs; -use self::markdown_help::cmd_util_markdown_help; +use self::install_man_pages::cmd_util_install_man_pages; use self::markdown_help::UtilMarkdownHelp; +use self::markdown_help::cmd_util_markdown_help; use crate::cli_util::CommandHelper; use crate::command_error::CommandError; use crate::ui::Ui; diff --git a/cli/src/commands/workspace/add.rs b/cli/src/commands/workspace/add.rs index d9d1eb7e2..95d5cf4c5 100644 --- a/cli/src/commands/workspace/add.rs +++ b/cli/src/commands/workspace/add.rs @@ -27,9 +27,9 @@ use tracing::instrument; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; +use crate::command_error::CommandError; use crate::command_error::internal_error_with_message; use crate::command_error::user_error; -use crate::command_error::CommandError; use crate::ui::Ui; /// How to handle sparse patterns when creating a new workspace. diff --git a/cli/src/commands/workspace/forget.rs b/cli/src/commands/workspace/forget.rs index a22fcad88..fad957478 100644 --- a/cli/src/commands/workspace/forget.rs +++ b/cli/src/commands/workspace/forget.rs @@ -18,8 +18,8 @@ use jj_lib::ref_name::WorkspaceNameBuf; use tracing::instrument; use crate::cli_util::CommandHelper; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::complete; use crate::ui::Ui; diff --git a/cli/src/commands/workspace/mod.rs b/cli/src/commands/workspace/mod.rs index bcbd08f7e..02b1f9c04 100644 --- a/cli/src/commands/workspace/mod.rs +++ b/cli/src/commands/workspace/mod.rs @@ -22,18 +22,18 @@ mod update_stale; use clap::Subcommand; use tracing::instrument; -use self::add::cmd_workspace_add; use self::add::WorkspaceAddArgs; -use self::forget::cmd_workspace_forget; +use self::add::cmd_workspace_add; use self::forget::WorkspaceForgetArgs; -use self::list::cmd_workspace_list; +use self::forget::cmd_workspace_forget; use self::list::WorkspaceListArgs; -use self::rename::cmd_workspace_rename; +use self::list::cmd_workspace_list; use self::rename::WorkspaceRenameArgs; -use self::root::cmd_workspace_root; +use self::rename::cmd_workspace_rename; use self::root::WorkspaceRootArgs; -use self::update_stale::cmd_workspace_update_stale; +use self::root::cmd_workspace_root; use self::update_stale::WorkspaceUpdateStaleArgs; +use self::update_stale::cmd_workspace_update_stale; use crate::cli_util::CommandHelper; use crate::command_error::CommandError; use crate::ui::Ui; diff --git a/cli/src/commands/workspace/rename.rs b/cli/src/commands/workspace/rename.rs index 44cbb5666..d7f9883c8 100644 --- a/cli/src/commands/workspace/rename.rs +++ b/cli/src/commands/workspace/rename.rs @@ -16,8 +16,8 @@ use jj_lib::ref_name::WorkspaceNameBuf; use tracing::instrument; use crate::cli_util::CommandHelper; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::ui::Ui; /// Renames the current workspace diff --git a/cli/src/commands/workspace/root.rs b/cli/src/commands/workspace/root.rs index c5b4af990..cb4e10a4c 100644 --- a/cli/src/commands/workspace/root.rs +++ b/cli/src/commands/workspace/root.rs @@ -18,8 +18,8 @@ use jj_lib::file_util; use tracing::instrument; use crate::cli_util::CommandHelper; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::ui::Ui; /// Show the current workspace root directory diff --git a/cli/src/commands/workspace/update_stale.rs b/cli/src/commands/workspace/update_stale.rs index 59d125712..83f312e68 100644 --- a/cli/src/commands/workspace/update_stale.rs +++ b/cli/src/commands/workspace/update_stale.rs @@ -14,8 +14,8 @@ use tracing::instrument; -use crate::cli_util::print_snapshot_stats; use crate::cli_util::CommandHelper; +use crate::cli_util::print_snapshot_stats; use crate::command_error::CommandError; use crate::ui::Ui; diff --git a/cli/src/commit_templater.rs b/cli/src/commit_templater.rs index 1a8fdb32e..283007c29 100644 --- a/cli/src/commit_templater.rs +++ b/cli/src/commit_templater.rs @@ -13,8 +13,8 @@ // limitations under the License. use std::any::Any; -use std::cmp::max; use std::cmp::Ordering; +use std::cmp::max; use std::collections::HashMap; use std::fmt; use std::fmt::Display; @@ -22,9 +22,9 @@ use std::io; use std::rc::Rc; use bstr::BString; -use futures::stream::BoxStream; use futures::StreamExt as _; use futures::TryStreamExt as _; +use futures::stream::BoxStream; use itertools::Itertools as _; use jj_lib::backend::BackendResult; use jj_lib::backend::ChangeId; @@ -77,14 +77,14 @@ use crate::diff_util::DiffStats; use crate::formatter::Formatter; use crate::revset_util; use crate::template_builder; -use crate::template_builder::expect_stringify_expression; -use crate::template_builder::merge_fn_map; use crate::template_builder::BuildContext; use crate::template_builder::CoreTemplateBuildFnTable; use crate::template_builder::CoreTemplatePropertyKind; use crate::template_builder::CoreTemplatePropertyVar; use crate::template_builder::TemplateBuildMethodFnMap; use crate::template_builder::TemplateLanguage; +use crate::template_builder::expect_stringify_expression; +use crate::template_builder::merge_fn_map; use crate::template_parser; use crate::template_parser::ExpressionNode; use crate::template_parser::FunctionCallNode; @@ -1883,8 +1883,8 @@ impl ShortestIdPrefix { } } -fn builtin_shortest_id_prefix_methods<'repo>( -) -> CommitTemplateBuildMethodFnMap<'repo, ShortestIdPrefix> { +fn builtin_shortest_id_prefix_methods<'repo>() +-> CommitTemplateBuildMethodFnMap<'repo, ShortestIdPrefix> { // Not using maplit::hashmap!{} or custom declarative macro here because // code completion inside macro is quite restricted. let mut map = CommitTemplateBuildMethodFnMap::::new(); @@ -2371,8 +2371,8 @@ impl CryptographicSignature { } } -fn builtin_cryptographic_signature_methods<'repo>( -) -> CommitTemplateBuildMethodFnMap<'repo, CryptographicSignature> { +fn builtin_cryptographic_signature_methods<'repo>() +-> CommitTemplateBuildMethodFnMap<'repo, CryptographicSignature> { // Not using maplit::hashmap!{} or custom declarative macro here because // code completion inside macro is quite restricted. let mut map = CommitTemplateBuildMethodFnMap::::new(); @@ -2526,9 +2526,9 @@ mod tests { use jj_lib::revset::RevsetExpression; use jj_lib::revset::RevsetExtensions; use jj_lib::revset::RevsetWorkspaceContext; - use testutils::repo_path_buf; use testutils::TestRepoBackend; use testutils::TestWorkspace; + use testutils::repo_path_buf; use super::*; use crate::template_parser::TemplateAliasesMap; diff --git a/cli/src/complete.rs b/cli/src/complete.rs index 5e5180597..ba2d3a348 100644 --- a/cli/src/complete.rs +++ b/cli/src/complete.rs @@ -15,8 +15,8 @@ use std::io::BufRead as _; use std::path::Path; -use clap::builder::StyledStr; use clap::FromArgMatches as _; +use clap::builder::StyledStr; use clap_complete::CompletionCandidate; use indoc::indoc; use itertools::Itertools as _; @@ -25,20 +25,20 @@ use jj_lib::settings::UserSettings; use jj_lib::workspace::DefaultWorkspaceLoaderFactory; use jj_lib::workspace::WorkspaceLoaderFactory as _; +use crate::cli_util::GlobalArgs; use crate::cli_util::expand_args; use crate::cli_util::find_workspace_dir; use crate::cli_util::load_template_aliases; -use crate::cli_util::GlobalArgs; -use crate::command_error::user_error; use crate::command_error::CommandError; -use crate::config::config_from_environment; -use crate::config::default_config_layers; +use crate::command_error::user_error; +use crate::config::CONFIG_SCHEMA; use crate::config::ConfigArgKind; use crate::config::ConfigEnv; -use crate::config::CONFIG_SCHEMA; +use crate::config::config_from_environment; +use crate::config::default_config_layers; +use crate::merge_tools::ExternalMergeTool; use crate::merge_tools::configured_merge_tools; use crate::merge_tools::get_external_tool_config; -use crate::merge_tools::ExternalMergeTool; use crate::revset_util::load_revset_aliases; use crate::ui::Ui; diff --git a/cli/src/config.rs b/cli/src/config.rs index eaaad10c2..3667f1dc6 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -40,9 +40,9 @@ use regex::Captures; use regex::Regex; use tracing::instrument; +use crate::command_error::CommandError; use crate::command_error::config_error; use crate::command_error::config_error_with_message; -use crate::command_error::CommandError; use crate::text_util; use crate::ui::Ui; diff --git a/cli/src/description_util.rs b/cli/src/description_util.rs index 777200439..d94425753 100644 --- a/cli/src/description_util.rs +++ b/cli/src/description_util.rs @@ -22,10 +22,10 @@ use jj_lib::trailer::parse_description_trailers; use jj_lib::trailer::parse_trailers; use thiserror::Error; -use crate::cli_util::short_commit_hash; use crate::cli_util::WorkspaceCommandTransaction; -use crate::command_error::user_error; +use crate::cli_util::short_commit_hash; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::config::CommandNameAndArgs; use crate::formatter::PlainTextFormatter; use crate::templater::TemplateRenderer; diff --git a/cli/src/diff_util.rs b/cli/src/diff_util.rs index e0b86f9ca..686c36eb9 100644 --- a/cli/src/diff_util.rs +++ b/cli/src/diff_util.rs @@ -24,10 +24,10 @@ use std::path::PathBuf; use bstr::BStr; use bstr::BString; use clap_complete::ArgValueCandidates; -use futures::executor::block_on_stream; -use futures::stream::BoxStream; use futures::StreamExt as _; use futures::TryStreamExt as _; +use futures::executor::block_on_stream; +use futures::stream::BoxStream; use itertools::Itertools as _; use jj_lib::backend::BackendError; use jj_lib::backend::BackendResult; @@ -36,23 +36,23 @@ use jj_lib::backend::CopyRecord; use jj_lib::backend::TreeValue; use jj_lib::commit::Commit; use jj_lib::config::ConfigGetError; -use jj_lib::conflicts::materialize_merge_result_to_bytes; -use jj_lib::conflicts::materialized_diff_stream; use jj_lib::conflicts::ConflictMarkerStyle; use jj_lib::conflicts::MaterializedFileValue; use jj_lib::conflicts::MaterializedTreeDiffEntry; use jj_lib::conflicts::MaterializedTreeValue; +use jj_lib::conflicts::materialize_merge_result_to_bytes; +use jj_lib::conflicts::materialized_diff_stream; use jj_lib::copies::CopiesTreeDiffEntry; use jj_lib::copies::CopiesTreeDiffEntryPath; use jj_lib::copies::CopyOperation; use jj_lib::copies::CopyRecords; -use jj_lib::diff::find_line_ranges; use jj_lib::diff::CompareBytesExactly; use jj_lib::diff::CompareBytesIgnoreAllWhitespace; use jj_lib::diff::CompareBytesIgnoreWhitespaceAmount; use jj_lib::diff::Diff; use jj_lib::diff::DiffHunk; use jj_lib::diff::DiffHunkKind; +use jj_lib::diff::find_line_ranges; use jj_lib::files; use jj_lib::files::ConflictDiffHunk; use jj_lib::files::DiffLineHunkSide; @@ -75,18 +75,18 @@ use thiserror::Error; use tracing::instrument; use unicode_width::UnicodeWidthStr as _; -use crate::command_error::cli_error; use crate::command_error::CommandError; +use crate::command_error::cli_error; use crate::commit_templater; use crate::config::CommandNameAndArgs; use crate::formatter::Formatter; use crate::merge_tools; -use crate::merge_tools::generate_diff; -use crate::merge_tools::invoke_external_diff; -use crate::merge_tools::new_utf8_temp_dir; use crate::merge_tools::DiffGenerateError; use crate::merge_tools::DiffToolMode; use crate::merge_tools::ExternalMergeTool; +use crate::merge_tools::generate_diff; +use crate::merge_tools::invoke_external_diff; +use crate::merge_tools::new_utf8_temp_dir; use crate::templater::TemplateRenderer; use crate::text_util; use crate::ui::Ui; diff --git a/cli/src/git_util.rs b/cli/src/git_util.rs index 484b446cc..c1f8fbdcc 100644 --- a/cli/src/git_util.rs +++ b/cli/src/git_util.rs @@ -45,9 +45,9 @@ use jj_lib::workspace::Workspace; use unicode_width::UnicodeWidthStr as _; use crate::cleanup_guard::CleanupGuard; +use crate::command_error::CommandError; use crate::command_error::cli_error; use crate::command_error::user_error; -use crate::command_error::CommandError; use crate::formatter::Formatter; use crate::ui::ProgressOutput; use crate::ui::Ui; diff --git a/cli/src/merge_tools/builtin.rs b/cli/src/merge_tools/builtin.rs index 6562f3c41..f90a1e121 100644 --- a/cli/src/merge_tools/builtin.rs +++ b/cli/src/merge_tools/builtin.rs @@ -2,19 +2,19 @@ use std::borrow::Cow; use std::path::Path; use std::sync::Arc; -use futures::stream::BoxStream; use futures::StreamExt as _; +use futures::stream::BoxStream; use itertools::Itertools as _; use jj_lib::backend::BackendResult; use jj_lib::backend::CopyId; use jj_lib::backend::MergedTreeId; use jj_lib::backend::TreeValue; use jj_lib::conflicts; +use jj_lib::conflicts::ConflictMarkerStyle; +use jj_lib::conflicts::MIN_CONFLICT_MARKER_LEN; +use jj_lib::conflicts::MaterializedTreeValue; use jj_lib::conflicts::materialize_merge_result_to_bytes; use jj_lib::conflicts::materialized_diff_stream; -use jj_lib::conflicts::ConflictMarkerStyle; -use jj_lib::conflicts::MaterializedTreeValue; -use jj_lib::conflicts::MIN_CONFLICT_MARKER_LEN; use jj_lib::copies::CopiesTreeDiffEntry; use jj_lib::copies::CopyRecords; use jj_lib::diff::Diff; @@ -726,16 +726,16 @@ mod tests { use jj_lib::matchers::FilesMatcher; use jj_lib::repo::Repo as _; use proptest::prelude::*; - use proptest_state_machine::prop_state_machine; use proptest_state_machine::ReferenceStateMachine; use proptest_state_machine::StateMachineTest; + use proptest_state_machine::prop_state_machine; + use testutils::TestRepo; use testutils::assert_tree_eq; use testutils::dump_tree; use testutils::proptest::Transition; use testutils::proptest::WorkingCopyReferenceStateMachine; use testutils::repo_path; use testutils::repo_path_component; - use testutils::TestRepo; use super::*; diff --git a/cli/src/merge_tools/diff_working_copies.rs b/cli/src/merge_tools/diff_working_copies.rs index 64a44fa8c..9ebb1d306 100644 --- a/cli/src/merge_tools/diff_working_copies.rs +++ b/cli/src/merge_tools/diff_working_copies.rs @@ -27,8 +27,8 @@ use pollster::FutureExt as _; use tempfile::TempDir; use thiserror::Error; -use super::external::ExternalToolError; use super::DiffEditError; +use super::external::ExternalToolError; #[derive(Debug, Error)] pub enum DiffCheckoutError { diff --git a/cli/src/merge_tools/external.rs b/cli/src/merge_tools/external.rs index 6f7bf5c80..a58708768 100644 --- a/cli/src/merge_tools/external.rs +++ b/cli/src/merge_tools/external.rs @@ -13,10 +13,10 @@ use jj_lib::backend::CopyId; use jj_lib::backend::MergedTreeId; use jj_lib::backend::TreeValue; use jj_lib::conflicts; -use jj_lib::conflicts::choose_materialized_conflict_marker_len; -use jj_lib::conflicts::materialize_merge_result_to_bytes_with_marker_len; use jj_lib::conflicts::ConflictMarkerStyle; use jj_lib::conflicts::MIN_CONFLICT_MARKER_LEN; +use jj_lib::conflicts::choose_materialized_conflict_marker_len; +use jj_lib::conflicts::materialize_merge_result_to_bytes_with_marker_len; use jj_lib::gitignore::GitIgnoreFile; use jj_lib::matchers::Matcher; use jj_lib::merge::Merge; @@ -28,19 +28,19 @@ use jj_lib::working_copy::CheckoutOptions; use pollster::FutureExt as _; use thiserror::Error; -use super::diff_working_copies::check_out_trees; -use super::diff_working_copies::new_utf8_temp_dir; -use super::diff_working_copies::set_readonly_recursively; -use super::diff_working_copies::DiffEditWorkingCopies; -use super::diff_working_copies::DiffSide; use super::ConflictResolveError; use super::DiffEditError; use super::DiffGenerateError; use super::MergeToolFile; use super::MergeToolPartialResolutionError; +use super::diff_working_copies::DiffEditWorkingCopies; +use super::diff_working_copies::DiffSide; +use super::diff_working_copies::check_out_trees; +use super::diff_working_copies::new_utf8_temp_dir; +use super::diff_working_copies::set_readonly_recursively; +use crate::config::CommandNameAndArgs; use crate::config::find_all_variables; use crate::config::interpolate_variables; -use crate::config::CommandNameAndArgs; use crate::ui::Ui; /// Merge/diff tool loaded from the settings. diff --git a/cli/src/merge_tools/mod.rs b/cli/src/merge_tools/mod.rs index f3512bff1..5f1bd06d6 100644 --- a/cli/src/merge_tools/mod.rs +++ b/cli/src/merge_tools/mod.rs @@ -26,9 +26,9 @@ use jj_lib::backend::TreeValue; use jj_lib::config::ConfigGetError; use jj_lib::config::ConfigGetResultExt as _; use jj_lib::config::ConfigNamePathBuf; -use jj_lib::conflicts::try_materialize_file_conflict_value; use jj_lib::conflicts::ConflictMarkerStyle; use jj_lib::conflicts::MaterializedFileConflictValue; +use jj_lib::conflicts::try_materialize_file_conflict_value; use jj_lib::gitignore::GitIgnoreFile; use jj_lib::matchers::Matcher; use jj_lib::merge::Merge; @@ -44,17 +44,17 @@ use jj_lib::working_copy::SnapshotError; use pollster::FutureExt as _; use thiserror::Error; +use self::builtin::BuiltinToolError; use self::builtin::edit_diff_builtin; use self::builtin::edit_merge_builtin; -use self::builtin::BuiltinToolError; -pub(crate) use self::diff_working_copies::new_utf8_temp_dir; use self::diff_working_copies::DiffCheckoutError; -use self::external::edit_diff_external; -pub use self::external::generate_diff; -pub use self::external::invoke_external_diff; +pub(crate) use self::diff_working_copies::new_utf8_temp_dir; pub use self::external::DiffToolMode; pub use self::external::ExternalMergeTool; use self::external::ExternalToolError; +use self::external::edit_diff_external; +pub use self::external::generate_diff; +pub use self::external::invoke_external_diff; use crate::config::CommandNameAndArgs; use crate::ui::Ui; diff --git a/cli/src/movement_util.rs b/cli/src/movement_util.rs index 1e6519bd0..02276062c 100644 --- a/cli/src/movement_util.rs +++ b/cli/src/movement_util.rs @@ -24,11 +24,11 @@ use jj_lib::revset::RevsetExpression; use jj_lib::revset::RevsetFilterPredicate; use jj_lib::revset::RevsetIteratorExt as _; -use crate::cli_util::short_commit_hash; use crate::cli_util::CommandHelper; use crate::cli_util::WorkspaceCommandHelper; -use crate::command_error::user_error; +use crate::cli_util::short_commit_hash; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::ui::Ui; #[derive(Clone, Debug, Eq, PartialEq)] diff --git a/cli/src/operation_templater.rs b/cli/src/operation_templater.rs index f64f5de97..a53d0a5f0 100644 --- a/cli/src/operation_templater.rs +++ b/cli/src/operation_templater.rs @@ -26,13 +26,13 @@ use jj_lib::repo::RepoLoader; use jj_lib::settings::UserSettings; use crate::template_builder; -use crate::template_builder::merge_fn_map; use crate::template_builder::BuildContext; use crate::template_builder::CoreTemplateBuildFnTable; use crate::template_builder::CoreTemplatePropertyKind; use crate::template_builder::CoreTemplatePropertyVar; use crate::template_builder::TemplateBuildMethodFnMap; use crate::template_builder::TemplateLanguage; +use crate::template_builder::merge_fn_map; use crate::template_parser; use crate::template_parser::FunctionCallNode; use crate::template_parser::TemplateDiagnostics; diff --git a/cli/src/revset_util.rs b/cli/src/revset_util.rs index ec2ebf1db..6dcd84807 100644 --- a/cli/src/revset_util.rs +++ b/cli/src/revset_util.rs @@ -45,8 +45,8 @@ use jj_lib::revset::SymbolResolverExtension; use jj_lib::revset::UserRevsetExpression; use thiserror::Error; -use crate::command_error::user_error; use crate::command_error::CommandError; +use crate::command_error::user_error; use crate::formatter::Formatter; use crate::templater::TemplateRenderer; use crate::ui::Ui; diff --git a/cli/src/template_builder.rs b/cli/src/template_builder.rs index 65e94e2d7..71d056361 100644 --- a/cli/src/template_builder.rs +++ b/cli/src/template_builder.rs @@ -25,8 +25,8 @@ use jj_lib::config::ConfigValue; use jj_lib::op_store::TimestampRange; use jj_lib::settings::UserSettings; use jj_lib::time_util::DatePattern; -use serde::de::IntoDeserializer as _; use serde::Deserialize; +use serde::de::IntoDeserializer as _; use crate::formatter::FormatRecorder; use crate::formatter::Formatter; @@ -870,8 +870,8 @@ fn build_binary_operation<'a, L: TemplateLanguage<'a> + ?Sized>( } } -fn builtin_string_methods<'a, L: TemplateLanguage<'a> + ?Sized>( -) -> TemplateBuildMethodFnMap<'a, L, String> { +fn builtin_string_methods<'a, L: TemplateLanguage<'a> + ?Sized>() +-> TemplateBuildMethodFnMap<'a, L, String> { // Not using maplit::hashmap!{} or custom declarative macro here because // code completion inside macro is quite restricted. let mut map = TemplateBuildMethodFnMap::::new(); @@ -1049,8 +1049,8 @@ fn string_index_to_char_boundary(s: &str, i: isize) -> usize { } } -fn builtin_config_value_methods<'a, L: TemplateLanguage<'a> + ?Sized>( -) -> TemplateBuildMethodFnMap<'a, L, ConfigValue> { +fn builtin_config_value_methods<'a, L: TemplateLanguage<'a> + ?Sized>() +-> TemplateBuildMethodFnMap<'a, L, ConfigValue> { fn extract<'de, T: Deserialize<'de>>(value: ConfigValue) -> Result { T::deserialize(value.into_deserializer()) // map to err.message() because TomlError appends newline to it @@ -1101,8 +1101,8 @@ fn builtin_config_value_methods<'a, L: TemplateLanguage<'a> + ?Sized>( map } -fn builtin_signature_methods<'a, L: TemplateLanguage<'a> + ?Sized>( -) -> TemplateBuildMethodFnMap<'a, L, Signature> { +fn builtin_signature_methods<'a, L: TemplateLanguage<'a> + ?Sized>() +-> TemplateBuildMethodFnMap<'a, L, Signature> { // Not using maplit::hashmap!{} or custom declarative macro here because // code completion inside macro is quite restricted. let mut map = TemplateBuildMethodFnMap::::new(); @@ -1149,8 +1149,8 @@ fn builtin_signature_methods<'a, L: TemplateLanguage<'a> + ?Sized>( map } -fn builtin_email_methods<'a, L: TemplateLanguage<'a> + ?Sized>( -) -> TemplateBuildMethodFnMap<'a, L, Email> { +fn builtin_email_methods<'a, L: TemplateLanguage<'a> + ?Sized>() +-> TemplateBuildMethodFnMap<'a, L, Email> { // Not using maplit::hashmap!{} or custom declarative macro here because // code completion inside macro is quite restricted. let mut map = TemplateBuildMethodFnMap::::new(); @@ -1179,8 +1179,8 @@ fn builtin_email_methods<'a, L: TemplateLanguage<'a> + ?Sized>( map } -fn builtin_size_hint_methods<'a, L: TemplateLanguage<'a> + ?Sized>( -) -> TemplateBuildMethodFnMap<'a, L, SizeHint> { +fn builtin_size_hint_methods<'a, L: TemplateLanguage<'a> + ?Sized>() +-> TemplateBuildMethodFnMap<'a, L, SizeHint> { // Not using maplit::hashmap!{} or custom declarative macro here because // code completion inside macro is quite restricted. let mut map = TemplateBuildMethodFnMap::::new(); @@ -1223,8 +1223,8 @@ fn builtin_size_hint_methods<'a, L: TemplateLanguage<'a> + ?Sized>( map } -fn builtin_timestamp_methods<'a, L: TemplateLanguage<'a> + ?Sized>( -) -> TemplateBuildMethodFnMap<'a, L, Timestamp> { +fn builtin_timestamp_methods<'a, L: TemplateLanguage<'a> + ?Sized>() +-> TemplateBuildMethodFnMap<'a, L, Timestamp> { // Not using maplit::hashmap!{} or custom declarative macro here because // code completion inside macro is quite restricted. let mut map = TemplateBuildMethodFnMap::::new(); @@ -1311,8 +1311,8 @@ fn builtin_timestamp_methods<'a, L: TemplateLanguage<'a> + ?Sized>( map } -fn builtin_timestamp_range_methods<'a, L: TemplateLanguage<'a> + ?Sized>( -) -> TemplateBuildMethodFnMap<'a, L, TimestampRange> { +fn builtin_timestamp_range_methods<'a, L: TemplateLanguage<'a> + ?Sized>() +-> TemplateBuildMethodFnMap<'a, L, TimestampRange> { // Not using maplit::hashmap!{} or custom declarative macro here because // code completion inside macro is quite restricted. let mut map = TemplateBuildMethodFnMap::::new(); @@ -1353,8 +1353,8 @@ fn builtin_timestamp_range_methods<'a, L: TemplateLanguage<'a> + ?Sized>( map } -fn builtin_list_template_methods<'a, L: TemplateLanguage<'a> + ?Sized>( -) -> BuildListTemplateMethodFnMap<'a, L> { +fn builtin_list_template_methods<'a, L: TemplateLanguage<'a> + ?Sized>() +-> BuildListTemplateMethodFnMap<'a, L> { // Not using maplit::hashmap!{} or custom declarative macro here because // code completion inside macro is quite restricted. let mut map = BuildListTemplateMethodFnMap::::new(); diff --git a/cli/src/template_parser.rs b/cli/src/template_parser.rs index 0eae22c6a..3a2076940 100644 --- a/cli/src/template_parser.rs +++ b/cli/src/template_parser.rs @@ -19,7 +19,6 @@ use std::sync::LazyLock; use itertools::Itertools as _; use jj_lib::dsl_util; -use jj_lib::dsl_util::collect_similar; use jj_lib::dsl_util::AliasDeclaration; use jj_lib::dsl_util::AliasDeclarationParser; use jj_lib::dsl_util::AliasDefinitionParser; @@ -33,12 +32,13 @@ use jj_lib::dsl_util::FoldableExpression; use jj_lib::dsl_util::FunctionCallParser; use jj_lib::dsl_util::InvalidArguments; use jj_lib::dsl_util::StringLiteralParser; +use jj_lib::dsl_util::collect_similar; +use pest::Parser as _; use pest::iterators::Pair; use pest::iterators::Pairs; use pest::pratt_parser::Assoc; use pest::pratt_parser::Op; use pest::pratt_parser::PrattParser; -use pest::Parser as _; use pest_derive::Parser; use thiserror::Error; diff --git a/cli/src/ui.rs b/cli/src/ui.rs index ec70ee5bd..dc464561b 100644 --- a/cli/src/ui.rs +++ b/cli/src/ui.rs @@ -305,8 +305,8 @@ struct StreampagerConfig { impl StreampagerConfig { fn streampager_interface_mode(&self) -> streampager::config::InterfaceMode { - use streampager::config::InterfaceMode; use StreampagerAlternateScreenMode::*; + use streampager::config::InterfaceMode; match self.interface { // InterfaceMode::Direct not implemented FullScreenClearOutput => InterfaceMode::FullScreen, diff --git a/cli/testing/fake-formatter.rs b/cli/testing/fake-formatter.rs index bf30c809b..c53d3282c 100644 --- a/cli/testing/fake-formatter.rs +++ b/cli/testing/fake-formatter.rs @@ -17,8 +17,8 @@ use std::io::Write as _; use std::path::PathBuf; use std::process::ExitCode; -use clap::arg; use clap::Parser; +use clap::arg; use itertools::Itertools as _; /// A fake code formatter, useful for testing diff --git a/cli/tests/test_abandon_command.rs b/cli/tests/test_abandon_command.rs index 3e3fb31a3..6cfa32388 100644 --- a/cli/tests/test_abandon_command.rs +++ b/cli/tests/test_abandon_command.rs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::common::create_commit; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::create_commit; #[test] fn test_basics() { diff --git a/cli/tests/test_backout_command.rs b/cli/tests/test_backout_command.rs index e600712c7..1e59a2d6a 100644 --- a/cli/tests/test_backout_command.rs +++ b/cli/tests/test_backout_command.rs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::common::create_commit_with_files; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::create_commit_with_files; #[test] fn test_backout() { diff --git a/cli/tests/test_commit_template.rs b/cli/tests/test_commit_template.rs index 8a5322724..d61a308c1 100644 --- a/cli/tests/test_commit_template.rs +++ b/cli/tests/test_commit_template.rs @@ -1033,8 +1033,8 @@ fn test_short_prefix_in_transaction() { // Short prefix should be used for commit summary inside the transaction let parent_id = "c0b41"; // Force id lookup to build index before mutation. - // If the cached index wasn't invalidated, the - // newly created commit wouldn't be found in it. + // If the cached index wasn't invalidated, the + // newly created commit wouldn't be found in it. let output = work_dir.run_jj(["new", parent_id, "--no-edit", "-m", "test"]); insta::assert_snapshot!(output, @r" ------- stderr ------- diff --git a/cli/tests/test_config_command.rs b/cli/tests/test_config_command.rs index 9aa68ce2a..65ec2df63 100644 --- a/cli/tests/test_config_command.rs +++ b/cli/tests/test_config_command.rs @@ -19,11 +19,11 @@ use indoc::indoc; use itertools::Itertools as _; use regex::Regex; +use crate::common::TestEnvironment; use crate::common::default_toml_from_schema; use crate::common::fake_editor_path; use crate::common::force_interactive; use crate::common::to_toml_value; -use crate::common::TestEnvironment; #[test] fn test_config_list_single() { diff --git a/cli/tests/test_diff_command.rs b/cli/tests/test_diff_command.rs index 8c0f5d2a7..812f7c825 100644 --- a/cli/tests/test_diff_command.rs +++ b/cli/tests/test_diff_command.rs @@ -15,13 +15,13 @@ use indoc::indoc; use itertools::Itertools as _; +use crate::common::CommandOutput; +use crate::common::TestEnvironment; +use crate::common::TestWorkDir; use crate::common::create_commit; use crate::common::create_commit_with_files; use crate::common::fake_diff_editor_path; use crate::common::to_toml_value; -use crate::common::CommandOutput; -use crate::common::TestEnvironment; -use crate::common::TestWorkDir; #[test] fn test_diff_basic() { diff --git a/cli/tests/test_duplicate_command.rs b/cli/tests/test_duplicate_command.rs index 034cc990b..da538cabb 100644 --- a/cli/tests/test_duplicate_command.rs +++ b/cli/tests/test_duplicate_command.rs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::common::create_commit; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::create_commit; #[test] fn test_duplicate() { diff --git a/cli/tests/test_evolog_command.rs b/cli/tests/test_evolog_command.rs index b3fbee0ee..1baf89cc4 100644 --- a/cli/tests/test_evolog_command.rs +++ b/cli/tests/test_evolog_command.rs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::common::to_toml_value; use crate::common::TestEnvironment; +use crate::common::to_toml_value; #[test] fn test_evolog_with_or_without_diff() { diff --git a/cli/tests/test_file_chmod_command.rs b/cli/tests/test_file_chmod_command.rs index 3d1e6bc59..6861efdb6 100644 --- a/cli/tests/test_file_chmod_command.rs +++ b/cli/tests/test_file_chmod_command.rs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::common::create_commit_with_files; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::create_commit_with_files; #[must_use] fn get_log_output(work_dir: &TestWorkDir) -> CommandOutput { diff --git a/cli/tests/test_fix_command.rs b/cli/tests/test_fix_command.rs index 6cb4bb2dd..801ded7e5 100644 --- a/cli/tests/test_fix_command.rs +++ b/cli/tests/test_fix_command.rs @@ -20,8 +20,8 @@ use indoc::formatdoc; use indoc::indoc; use jj_lib::file_util::try_symlink; -use crate::common::to_toml_value; use crate::common::TestEnvironment; +use crate::common::to_toml_value; fn set_up_fake_formatter(test_env: &TestEnvironment, args: &[&str]) { let formatter_path = assert_cmd::cargo::cargo_bin("fake-formatter"); diff --git a/cli/tests/test_git_clone.rs b/cli/tests/test_git_clone.rs index 36f86824d..d57ff1d0c 100644 --- a/cli/tests/test_git_clone.rs +++ b/cli/tests/test_git_clone.rs @@ -18,10 +18,10 @@ use indoc::formatdoc; use indoc::indoc; use testutils::git; -use crate::common::to_toml_value; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::to_toml_value; fn set_up_non_empty_git_repo(git_repo: &gix::Repository) { set_up_git_repo_with_file(git_repo, "file"); diff --git a/cli/tests/test_git_fetch.rs b/cli/tests/test_git_fetch.rs index e0b85e246..9382f8bb5 100644 --- a/cli/tests/test_git_fetch.rs +++ b/cli/tests/test_git_fetch.rs @@ -14,10 +14,10 @@ use testutils::git; -use crate::common::create_commit; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::create_commit; fn add_commit_to_branch(git_repo: &gix::Repository, branch: &str) -> gix::ObjectId { git::add_commit( diff --git a/cli/tests/test_git_init.rs b/cli/tests/test_git_init.rs index 393a4e842..c2ac37186 100644 --- a/cli/tests/test_git_init.rs +++ b/cli/tests/test_git_init.rs @@ -19,10 +19,10 @@ use indoc::formatdoc; use test_case::test_case; use testutils::git; -use crate::common::to_toml_value; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::to_toml_value; fn init_git_repo(git_repo_path: &Path, bare: bool) -> gix::Repository { let git_repo = if bare { @@ -334,9 +334,11 @@ fn test_git_init_colocated_via_git_repo_path() { assert!(jj_path.join("working_copy").is_dir()); assert!(repo_path.is_dir()); assert!(store_path.is_dir()); - assert!(read_git_target(&work_dir) - .replace('\\', "/") - .ends_with("../../../.git")); + assert!( + read_git_target(&work_dir) + .replace('\\', "/") + .ends_with("../../../.git") + ); // Check that the Git repo's HEAD got checked out insta::assert_snapshot!(get_log_output(&work_dir), @r" diff --git a/cli/tests/test_git_push.rs b/cli/tests/test_git_push.rs index f630d3626..e70aa6592 100644 --- a/cli/tests/test_git_push.rs +++ b/cli/tests/test_git_push.rs @@ -14,10 +14,10 @@ use testutils::git; -use crate::common::to_toml_value; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::to_toml_value; fn git_repo_dir_for_jj_repo(work_dir: &TestWorkDir<'_>) -> std::path::PathBuf { work_dir diff --git a/cli/tests/test_log_command.rs b/cli/tests/test_log_command.rs index 93cb63362..17dedb50b 100644 --- a/cli/tests/test_log_command.rs +++ b/cli/tests/test_log_command.rs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::common::to_toml_value; use crate::common::TestEnvironment; +use crate::common::to_toml_value; #[test] fn test_log_with_empty_revision() { diff --git a/cli/tests/test_next_prev_commands.rs b/cli/tests/test_next_prev_commands.rs index 243c836db..6aa4e218b 100644 --- a/cli/tests/test_next_prev_commands.rs +++ b/cli/tests/test_next_prev_commands.rs @@ -13,10 +13,10 @@ // limitations under the License. // -use crate::common::force_interactive; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::force_interactive; #[test] fn test_next_simple() { diff --git a/cli/tests/test_operations.rs b/cli/tests/test_operations.rs index 3326e6b3d..6d04d31cc 100644 --- a/cli/tests/test_operations.rs +++ b/cli/tests/test_operations.rs @@ -19,10 +19,10 @@ use itertools::Itertools as _; use regex::Regex; use testutils::git; -use crate::common::to_toml_value; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::to_toml_value; #[test] fn test_op_log() { diff --git a/cli/tests/test_rebase_command.rs b/cli/tests/test_rebase_command.rs index 94f565562..ea2d472d0 100644 --- a/cli/tests/test_rebase_command.rs +++ b/cli/tests/test_rebase_command.rs @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::common::create_commit; -use crate::common::create_commit_with_files; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::create_commit; +use crate::common::create_commit_with_files; #[test] fn test_rebase_invalid() { diff --git a/cli/tests/test_resolve_command.rs b/cli/tests/test_resolve_command.rs index 81ea13958..16ae6bcd7 100644 --- a/cli/tests/test_resolve_command.rs +++ b/cli/tests/test_resolve_command.rs @@ -16,10 +16,10 @@ use std::path::Path; use indoc::indoc; -use crate::common::create_commit_with_files; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::create_commit_with_files; #[must_use] fn get_log_output(work_dir: &TestWorkDir) -> CommandOutput { diff --git a/cli/tests/test_restore_command.rs b/cli/tests/test_restore_command.rs index 5f066afca..b8cffd10e 100644 --- a/cli/tests/test_restore_command.rs +++ b/cli/tests/test_restore_command.rs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::common::create_commit_with_files; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::create_commit_with_files; #[test] fn test_restore() { diff --git a/cli/tests/test_revert_command.rs b/cli/tests/test_revert_command.rs index 6c193bbfe..961a002f7 100644 --- a/cli/tests/test_revert_command.rs +++ b/cli/tests/test_revert_command.rs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::common::create_commit_with_files; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; +use crate::common::create_commit_with_files; #[test] fn test_revert() { diff --git a/cli/tests/test_simplify_parents_command.rs b/cli/tests/test_simplify_parents_command.rs index 1a6e60c05..3fe0da3f6 100644 --- a/cli/tests/test_simplify_parents_command.rs +++ b/cli/tests/test_simplify_parents_command.rs @@ -14,8 +14,8 @@ use test_case::test_case; -use crate::common::create_commit; use crate::common::TestEnvironment; +use crate::common::create_commit; #[test] fn test_simplify_parents_no_commits() { diff --git a/cli/tests/test_status_command.rs b/cli/tests/test_status_command.rs index 5491e4e2c..524420273 100644 --- a/cli/tests/test_status_command.rs +++ b/cli/tests/test_status_command.rs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::common::create_commit_with_files; use crate::common::TestEnvironment; +use crate::common::create_commit_with_files; #[test] fn test_status_copies() { diff --git a/lib/benches/diff_bench.rs b/lib/benches/diff_bench.rs index d0cddebb3..c1c8bf4b4 100644 --- a/lib/benches/diff_bench.rs +++ b/lib/benches/diff_bench.rs @@ -1,7 +1,7 @@ -use criterion::criterion_group; -use criterion::criterion_main; use criterion::BenchmarkId; use criterion::Criterion; +use criterion::criterion_group; +use criterion::criterion_main; use jj_lib::diff; fn unchanged_lines(count: usize) -> (String, String) { diff --git a/lib/proc-macros/src/content_hash.rs b/lib/proc-macros/src/content_hash.rs index 2d736eea8..52c0703c0 100644 --- a/lib/proc-macros/src/content_hash.rs +++ b/lib/proc-macros/src/content_hash.rs @@ -3,8 +3,6 @@ use proc_macro2::TokenStream; use quote::format_ident; use quote::quote; use quote::quote_spanned; -use syn::parse_quote; -use syn::spanned::Spanned as _; use syn::Data; use syn::Field; use syn::Fields; @@ -12,6 +10,8 @@ use syn::GenericParam; use syn::Generics; use syn::Index; use syn::Type; +use syn::parse_quote; +use syn::spanned::Spanned as _; pub fn add_trait_bounds(mut generics: Generics) -> Generics { for param in &mut generics.params { diff --git a/lib/proc-macros/src/lib.rs b/lib/proc-macros/src/lib.rs index de3e36544..8f0a679d9 100644 --- a/lib/proc-macros/src/lib.rs +++ b/lib/proc-macros/src/lib.rs @@ -3,8 +3,8 @@ mod content_hash; extern crate proc_macro; use quote::quote; -use syn::parse_macro_input; use syn::DeriveInput; +use syn::parse_macro_input; /// Derive macro generating an impl of the trait `ContentHash`. /// diff --git a/lib/src/absorb.rs b/lib/src/absorb.rs index 587bbaa10..fce4830d7 100644 --- a/lib/src/absorb.rs +++ b/lib/src/absorb.rs @@ -32,9 +32,9 @@ use crate::backend::BackendResult; use crate::backend::CommitId; use crate::backend::TreeValue; use crate::commit::Commit; -use crate::conflicts::materialized_diff_stream; use crate::conflicts::MaterializedFileValue; use crate::conflicts::MaterializedTreeValue; +use crate::conflicts::materialized_diff_stream; use crate::copies::CopyRecords; use crate::diff::Diff; use crate::diff::DiffHunkKind; diff --git a/lib/src/annotate.rs b/lib/src/annotate.rs index c020a3578..bdcb4d3c7 100644 --- a/lib/src/annotate.rs +++ b/lib/src/annotate.rs @@ -18,8 +18,8 @@ //! TODO: Add support for different blame layers with a trait in the future. //! Like commit metadata and more. -use std::collections::hash_map; use std::collections::HashMap; +use std::collections::hash_map; use std::iter; use std::ops::Range; use std::rc::Rc; @@ -33,10 +33,10 @@ use crate::backend::BackendError; use crate::backend::BackendResult; use crate::backend::CommitId; use crate::commit::Commit; -use crate::conflicts::materialize_merge_result_to_bytes; -use crate::conflicts::materialize_tree_value; use crate::conflicts::ConflictMarkerStyle; use crate::conflicts::MaterializedTreeValue; +use crate::conflicts::materialize_merge_result_to_bytes; +use crate::conflicts::materialize_tree_value; use crate::diff::Diff; use crate::diff::DiffHunkKind; use crate::fileset::FilesetExpression; diff --git a/lib/src/backend.rs b/lib/src/backend.rs index c94835a41..029ff1dc6 100644 --- a/lib/src/backend.rs +++ b/lib/src/backend.rs @@ -30,8 +30,8 @@ use crate::content_hash::ContentHash; use crate::hex_util; use crate::index::Index; use crate::merge::Merge; -use crate::object_id::id_type; use crate::object_id::ObjectId as _; +use crate::object_id::id_type; use crate::repo_path::RepoPath; use crate::repo_path::RepoPathBuf; use crate::repo_path::RepoPathComponent; diff --git a/lib/src/commit_builder.rs b/lib/src/commit_builder.rs index c6ca7d211..2d80d2cfc 100644 --- a/lib/src/commit_builder.rs +++ b/lib/src/commit_builder.rs @@ -25,8 +25,8 @@ use crate::backend::ChangeId; use crate::backend::CommitId; use crate::backend::MergedTreeId; use crate::backend::Signature; -use crate::commit::is_backend_commit_empty; use crate::commit::Commit; +use crate::commit::is_backend_commit_empty; use crate::repo::MutableRepo; use crate::repo::Repo; use crate::settings::JJRng; diff --git a/lib/src/config.rs b/lib/src/config.rs index b4c125c6d..7183922ea 100644 --- a/lib/src/config.rs +++ b/lib/src/config.rs @@ -29,18 +29,18 @@ use std::sync::Arc; use std::sync::LazyLock; use itertools::Itertools as _; -use serde::de::IntoDeserializer as _; use serde::Deserialize; +use serde::de::IntoDeserializer as _; use thiserror::Error; use toml_edit::DocumentMut; use toml_edit::ImDocument; -pub use crate::config_resolver::migrate; -pub use crate::config_resolver::resolve; pub use crate::config_resolver::ConfigMigrateError; pub use crate::config_resolver::ConfigMigrateLayerError; pub use crate::config_resolver::ConfigMigrationRule; pub use crate::config_resolver::ConfigResolutionContext; +pub use crate::config_resolver::migrate; +pub use crate::config_resolver::resolve; use crate::file_util::IoResultExt as _; use crate::file_util::PathError; diff --git a/lib/src/config_resolver.rs b/lib/src/config_resolver.rs index 530a45c1a..2b1707128 100644 --- a/lib/src/config_resolver.rs +++ b/lib/src/config_resolver.rs @@ -19,8 +19,8 @@ use std::path::PathBuf; use std::sync::Arc; use itertools::Itertools as _; -use serde::de::IntoDeserializer as _; use serde::Deserialize as _; +use serde::de::IntoDeserializer as _; use thiserror::Error; use toml_edit::DocumentMut; diff --git a/lib/src/conflicts.rs b/lib/src/conflicts.rs index 70829b4ff..124a5de70 100644 --- a/lib/src/conflicts.rs +++ b/lib/src/conflicts.rs @@ -21,10 +21,10 @@ use std::pin::Pin; use bstr::BString; use bstr::ByteSlice as _; -use futures::stream::BoxStream; -use futures::try_join; use futures::Stream; use futures::StreamExt as _; +use futures::stream::BoxStream; +use futures::try_join; use itertools::Itertools as _; use pollster::FutureExt as _; use tokio::io::AsyncRead; diff --git a/lib/src/copies.rs b/lib/src/copies.rs index 9f1379e84..6f83558c1 100644 --- a/lib/src/copies.rs +++ b/lib/src/copies.rs @@ -16,9 +16,9 @@ use std::collections::HashMap; use std::pin::Pin; -use std::task::ready; use std::task::Context; use std::task::Poll; +use std::task::ready; use futures::Stream; diff --git a/lib/src/dag_walk.rs b/lib/src/dag_walk.rs index 6cb0cd2af..a0310c68c 100644 --- a/lib/src/dag_walk.rs +++ b/lib/src/dag_walk.rs @@ -23,8 +23,8 @@ use std::iter; use std::mem; use itertools::Itertools as _; -use smallvec::smallvec_inline; use smallvec::SmallVec; +use smallvec::smallvec_inline; /// Traverses nodes from `start` in depth-first order. pub fn dfs( @@ -57,20 +57,22 @@ where { let mut work: Vec> = start.into_iter().collect(); let mut visited: HashSet = HashSet::new(); - iter::from_fn(move || loop { - let c = match work.pop() { - Some(Ok(c)) => c, - r @ (Some(Err(_)) | None) => return r, - }; - let id = id_fn(&c); - if visited.contains(&id) { - continue; + iter::from_fn(move || { + loop { + let c = match work.pop() { + Some(Ok(c)) => c, + r @ (Some(Err(_)) | None) => return r, + }; + let id = id_fn(&c); + if visited.contains(&id) { + continue; + } + for p in neighbors_fn(&c) { + work.push(p); + } + visited.insert(id); + return Some(Ok(c)); } - for p in neighbors_fn(&c) { - work.push(p); - } - visited.insert(id); - return Some(Ok(c)); }) } @@ -521,9 +523,11 @@ where neighbor_ids_map.insert(node_id, neighbor_ids); } - debug_assert!(head_node_map - .keys() - .all(|id| !inner_node_map.contains_key(id))); + debug_assert!( + head_node_map + .keys() + .all(|id| !inner_node_map.contains_key(id)) + ); debug_assert!(inner_node_map.values().all(|inner| inner.node.is_some())); debug_assert!(inner_node_map.values().all(|inner| inner.indegree > 0)); diff --git a/lib/src/default_index/composite.rs b/lib/src/default_index/composite.rs index 8c255cf2d..8043b5336 100644 --- a/lib/src/default_index/composite.rs +++ b/lib/src/default_index/composite.rs @@ -14,20 +14,20 @@ #![allow(missing_docs)] -use std::cmp::max; use std::cmp::Ordering; use std::cmp::Reverse; -use std::collections::binary_heap; +use std::cmp::max; use std::collections::BinaryHeap; use std::collections::HashSet; +use std::collections::binary_heap; use std::iter; use std::mem; use std::sync::Arc; use std::sync::Mutex; use itertools::Itertools as _; -use ref_cast::ref_cast_custom; use ref_cast::RefCastCustom; +use ref_cast::ref_cast_custom; use super::bit_set::AncestorsBitSet; use super::bit_set::PositionsBitSet; @@ -46,10 +46,10 @@ use crate::index::AllHeadsForGcUnsupported; use crate::index::ChangeIdIndex; use crate::index::Index; use crate::index::IndexError; -use crate::object_id::id_type; use crate::object_id::HexPrefix; use crate::object_id::ObjectId as _; use crate::object_id::PrefixResolution; +use crate::object_id::id_type; use crate::revset::ResolvedExpression; use crate::revset::Revset; use crate::revset::RevsetEvaluationError; diff --git a/lib/src/default_index/mutable.rs b/lib/src/default_index/mutable.rs index 50db31c58..1ea53f657 100644 --- a/lib/src/default_index/mutable.rs +++ b/lib/src/default_index/mutable.rs @@ -30,8 +30,8 @@ use std::sync::Arc; use blake2::Blake2b512; use digest::Digest as _; use itertools::Itertools as _; -use smallvec::smallvec; use smallvec::SmallVec; +use smallvec::smallvec; use tempfile::NamedTempFile; use super::composite::AsCompositeIndex; @@ -45,11 +45,11 @@ use super::entry::GlobalCommitPosition; use super::entry::LocalCommitPosition; use super::entry::SmallGlobalCommitPositionsVec; use super::entry::SmallLocalCommitPositionsVec; +use super::readonly::COMMIT_INDEX_SEGMENT_FILE_FORMAT_VERSION; use super::readonly::DefaultReadonlyIndex; use super::readonly::FieldLengths; -use super::readonly::ReadonlyCommitIndexSegment; -use super::readonly::COMMIT_INDEX_SEGMENT_FILE_FORMAT_VERSION; use super::readonly::OVERFLOW_FLAG; +use super::readonly::ReadonlyCommitIndexSegment; use crate::backend::ChangeId; use crate::backend::CommitId; use crate::commit::Commit; diff --git a/lib/src/default_index/rev_walk.rs b/lib/src/default_index/rev_walk.rs index b4ef54465..085181915 100644 --- a/lib/src/default_index/rev_walk.rs +++ b/lib/src/default_index/rev_walk.rs @@ -14,8 +14,8 @@ #![allow(missing_docs)] -use std::cmp::max; use std::cmp::Reverse; +use std::cmp::max; use std::collections::HashMap; use std::collections::HashSet; use std::iter::Fuse; diff --git a/lib/src/default_index/revset_engine.rs b/lib/src/default_index/revset_engine.rs index d98460d32..7aaf009ae 100644 --- a/lib/src/default_index/revset_engine.rs +++ b/lib/src/default_index/revset_engine.rs @@ -44,8 +44,8 @@ use crate::backend::ChangeId; use crate::backend::CommitId; use crate::backend::MillisSinceEpoch; use crate::commit::Commit; -use crate::conflicts::materialize_tree_value; use crate::conflicts::MaterializedTreeValue; +use crate::conflicts::materialize_tree_value; use crate::diff::Diff; use crate::diff::DiffHunkKind; use crate::files; @@ -56,13 +56,13 @@ use crate::merge::Merge; use crate::merged_tree::resolve_file_values; use crate::object_id::ObjectId as _; use crate::repo_path::RepoPath; +use crate::revset::GENERATION_RANGE_FULL; use crate::revset::ResolvedExpression; use crate::revset::ResolvedPredicateExpression; use crate::revset::Revset; use crate::revset::RevsetContainingFn; use crate::revset::RevsetEvaluationError; use crate::revset::RevsetFilterPredicate; -use crate::revset::GENERATION_RANGE_FULL; use crate::rewrite; use crate::store::Store; use crate::str_util::StringPattern; @@ -1470,8 +1470,8 @@ mod tests { use indoc::indoc; use super::*; - use crate::default_index::readonly::FieldLengths; use crate::default_index::DefaultMutableIndex; + use crate::default_index::readonly::FieldLengths; const TEST_FIELD_LENGTHS: FieldLengths = FieldLengths { commit_id: 3, @@ -1777,9 +1777,11 @@ mod tests { // Does not consume positions for unknown commits let positions_accum = PositionsAccumulator::new(index, full_set.positions()); - assert!(!positions_accum - .contains(&CommitId::from_hex("999999")) - .unwrap()); + assert!( + !positions_accum + .contains(&CommitId::from_hex("999999")) + .unwrap() + ); assert_eq!(positions_accum.consumed_len(), 0); // Does not consume without necessity diff --git a/lib/src/default_index/revset_graph_iterator.rs b/lib/src/default_index/revset_graph_iterator.rs index e8d6c26ad..a0e353095 100644 --- a/lib/src/default_index/revset_graph_iterator.rs +++ b/lib/src/default_index/revset_graph_iterator.rs @@ -14,8 +14,8 @@ #![allow(missing_docs)] -use std::cmp::min; use std::cmp::Ordering; +use std::cmp::min; use std::collections::BTreeMap; use std::collections::VecDeque; diff --git a/lib/src/default_index/store.rs b/lib/src/default_index/store.rs index 93086a278..5a011936a 100644 --- a/lib/src/default_index/store.rs +++ b/lib/src/default_index/store.rs @@ -41,9 +41,9 @@ use crate::backend::CommitId; use crate::commit::CommitByCommitterTimestamp; use crate::dag_walk; use crate::file_util; -use crate::file_util::persist_content_addressed_temp_file; use crate::file_util::IoResultExt as _; use crate::file_util::PathError; +use crate::file_util::persist_content_addressed_temp_file; use crate::index::Index as _; use crate::index::IndexReadError; use crate::index::IndexStore; diff --git a/lib/src/diff.rs b/lib/src/diff.rs index 18d91ab4d..4d85f814a 100644 --- a/lib/src/diff.rs +++ b/lib/src/diff.rs @@ -26,8 +26,8 @@ use std::slice; use bstr::BStr; use hashbrown::HashTable; use itertools::Itertools as _; -use smallvec::smallvec; use smallvec::SmallVec; +use smallvec::smallvec; pub fn find_line_ranges(text: &[u8]) -> Vec> { text.split_inclusive(|b| *b == b'\n') diff --git a/lib/src/dsl_util.rs b/lib/src/dsl_util.rs index 1119c8863..da7d8976b 100644 --- a/lib/src/dsl_util.rs +++ b/lib/src/dsl_util.rs @@ -20,9 +20,9 @@ use std::fmt; use std::slice; use itertools::Itertools as _; +use pest::RuleType; use pest::iterators::Pair; use pest::iterators::Pairs; -use pest::RuleType; /// Manages diagnostic messages emitted during parsing. /// diff --git a/lib/src/extensions_map.rs b/lib/src/extensions_map.rs index 312f11265..72465abbd 100644 --- a/lib/src/extensions_map.rs +++ b/lib/src/extensions_map.rs @@ -44,10 +44,11 @@ impl ExtensionsMap { /// /// Requires that this type has not been inserted before. pub fn insert(&mut self, value: V) { - assert!(self - .values - .insert(TypeId::of::(), Box::new(value)) - .is_none()); + assert!( + self.values + .insert(TypeId::of::(), Box::new(value)) + .is_none() + ); } } diff --git a/lib/src/file_util.rs b/lib/src/file_util.rs index 47b224816..39e89e910 100644 --- a/lib/src/file_util.rs +++ b/lib/src/file_util.rs @@ -303,12 +303,12 @@ mod platform { use std::os::windows::fs::symlink_file; use std::path::Path; - use winreg::enums::HKEY_LOCAL_MACHINE; use winreg::RegKey; + use winreg::enums::HKEY_LOCAL_MACHINE; + pub use super::fallback::BadOsStrEncoding; pub use super::fallback::os_str_from_bytes; pub use super::fallback::os_str_to_bytes; - pub use super::fallback::BadOsStrEncoding; /// Symlinks may or may not be enabled on Windows. They require the /// Developer Mode setting, which is stored in the registry key below. diff --git a/lib/src/fileset_parser.rs b/lib/src/fileset_parser.rs index 8ce9f1629..845487a4c 100644 --- a/lib/src/fileset_parser.rs +++ b/lib/src/fileset_parser.rs @@ -18,11 +18,11 @@ use std::error; use std::sync::LazyLock; use itertools::Itertools as _; +use pest::Parser as _; use pest::iterators::Pair; use pest::pratt_parser::Assoc; use pest::pratt_parser::Op; use pest::pratt_parser::PrattParser; -use pest::Parser as _; use pest_derive::Parser; use thiserror::Error; diff --git a/lib/src/git.rs b/lib/src/git.rs index 86d5a24f4..532eb140e 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -1925,7 +1925,7 @@ pub fn rename_remote( _ => { return Err(GitRemoteManagementError::NonstandardConfiguration( old_remote_name.to_owned(), - )) + )); } } diff --git a/lib/src/git_backend.rs b/lib/src/git_backend.rs index 48f9ca184..e37b637b5 100644 --- a/lib/src/git_backend.rs +++ b/lib/src/git_backend.rs @@ -49,7 +49,6 @@ use thiserror::Error; use tokio::io::AsyncRead; use tokio::io::AsyncReadExt as _; -use crate::backend::make_root_commit; use crate::backend::Backend; use crate::backend::BackendError; use crate::backend::BackendInitError; @@ -75,6 +74,7 @@ use crate::backend::Timestamp; use crate::backend::Tree; use crate::backend::TreeId; use crate::backend::TreeValue; +use crate::backend::make_root_commit; use crate::config::ConfigGetError; use crate::file_util; use crate::file_util::BadPathEncoding; @@ -1879,10 +1879,12 @@ mod tests { // read_commit() without import_head_commits() works as of now. This might be // changed later. - assert!(backend - .read_commit(&CommitId::from_bytes(git_commit_id.as_bytes())) - .block_on() - .is_ok()); + assert!( + backend + .read_commit(&CommitId::from_bytes(git_commit_id.as_bytes())) + .block_on() + .is_ok() + ); assert!( backend .cached_extra_metadata_table() @@ -2163,11 +2165,13 @@ mod tests { )) .unwrap(); let git_tree = git_repo.find_tree(git_commit.tree_id().unwrap()).unwrap(); - assert!(git_tree - .iter() - .map(Result::unwrap) - .filter(|entry| entry.filename() != b"README") - .all(|entry| entry.mode().value() == 0o040000)); + assert!( + git_tree + .iter() + .map(Result::unwrap) + .filter(|entry| entry.filename() != b"README") + .all(|entry| entry.mode().value() == 0o040000) + ); let mut iter = git_tree.iter().map(Result::unwrap); let entry = iter.next().unwrap(); assert_eq!(entry.filename(), b".jjconflict-base-0"); @@ -2300,12 +2304,14 @@ mod tests { backend .import_head_commits([&commit_id, &commit_id]) .unwrap(); - assert!(git_repo - .references() - .unwrap() - .prefixed("refs/jj/keep/") - .unwrap() - .any(|git_ref| git_ref.unwrap().id().detach() == git_commit_id)); + assert!( + git_repo + .references() + .unwrap() + .prefixed("refs/jj/keep/") + .unwrap() + .any(|git_ref| git_ref.unwrap().id().detach() == git_commit_id) + ); } #[test] diff --git a/lib/src/git_subprocess.rs b/lib/src/git_subprocess.rs index e8cf2901e..7dd287a8a 100644 --- a/lib/src/git_subprocess.rs +++ b/lib/src/git_subprocess.rs @@ -917,8 +917,10 @@ Done"; let (output, sideband, progress) = read(sample.as_bytes()); assert_eq!( sideband, - ["line1", "\n", "line2.0", "\r", "line2.1", "\n", "line3", "\n"] - .map(|s| s.as_bytes().to_owned()) + [ + "line1", "\n", "line2.0", "\r", "line2.1", "\n", "line3", "\n" + ] + .map(|s| s.as_bytes().to_owned()) ); assert_eq!(output, b"blah blah\nsome error message\n"); insta::assert_debug_snapshot!(progress, @r" @@ -934,8 +936,10 @@ Done"; let (output, sideband, _progress) = read(sample.as_bytes().trim_end()); assert_eq!( sideband, - ["line1", "\n", "line2.0", "\r", "line2.1", "\n", "line3", "\n"] - .map(|s| s.as_bytes().to_owned()) + [ + "line1", "\n", "line2.0", "\r", "line2.1", "\n", "line3", "\n" + ] + .map(|s| s.as_bytes().to_owned()) ); assert_eq!(output, b"blah blah\nsome error message"); } diff --git a/lib/src/gitignore.rs b/lib/src/gitignore.rs index d3143c87c..838437518 100644 --- a/lib/src/gitignore.rs +++ b/lib/src/gitignore.rs @@ -272,9 +272,11 @@ mod tests { assert!(matches(b"\\?\n", "?")); assert!(!matches(b"\\?\n", "x")); assert!(matches(b"\\w\n", "w")); - assert!(GitIgnoreFile::empty() - .chain("", Path::new(""), b"\\\n") - .is_err()); + assert!( + GitIgnoreFile::empty() + .chain("", Path::new(""), b"\\\n") + .is_err() + ); } #[test] @@ -327,9 +329,11 @@ mod tests { assert!(matches(b"a\r\r\n", "a")); assert!(matches(b"\ra\n", "\ra")); assert!(!matches(b"\ra\n", "a")); - assert!(GitIgnoreFile::empty() - .chain("", Path::new(""), b"a b \\ \n") - .is_err()); + assert!( + GitIgnoreFile::empty() + .chain("", Path::new(""), b"a b \\ \n") + .is_err() + ); } #[test] diff --git a/lib/src/id_prefix.rs b/lib/src/id_prefix.rs index b1209c676..e30a82c8f 100644 --- a/lib/src/id_prefix.rs +++ b/lib/src/id_prefix.rs @@ -666,30 +666,42 @@ mod tests { // No crash if empty let source: Vec<(ChangeId, ())> = vec![]; let id_index = build_id_index::<_, 1>(&source); - assert!(id_index - .lookup_exact(&*source, &ChangeId::from_hex("00")) - .is_none()); + assert!( + id_index + .lookup_exact(&*source, &ChangeId::from_hex("00")) + .is_none() + ); let source = vec![ (ChangeId::from_hex("ab00"), ()), (ChangeId::from_hex("ab01"), ()), ]; let id_index = build_id_index::<_, 1>(&source); - assert!(id_index - .lookup_exact(&*source, &ChangeId::from_hex("aa00")) - .is_none()); - assert!(id_index - .lookup_exact(&*source, &ChangeId::from_hex("ab00")) - .is_some()); - assert!(id_index - .lookup_exact(&*source, &ChangeId::from_hex("ab01")) - .is_some()); - assert!(id_index - .lookup_exact(&*source, &ChangeId::from_hex("ab02")) - .is_none()); - assert!(id_index - .lookup_exact(&*source, &ChangeId::from_hex("ac00")) - .is_none()); + assert!( + id_index + .lookup_exact(&*source, &ChangeId::from_hex("aa00")) + .is_none() + ); + assert!( + id_index + .lookup_exact(&*source, &ChangeId::from_hex("ab00")) + .is_some() + ); + assert!( + id_index + .lookup_exact(&*source, &ChangeId::from_hex("ab01")) + .is_some() + ); + assert!( + id_index + .lookup_exact(&*source, &ChangeId::from_hex("ab02")) + .is_none() + ); + assert!( + id_index + .lookup_exact(&*source, &ChangeId::from_hex("ac00")) + .is_none() + ); } #[test] diff --git a/lib/src/index.rs b/lib/src/index.rs index 1bc69518d..17b43c3b3 100644 --- a/lib/src/index.rs +++ b/lib/src/index.rs @@ -142,7 +142,7 @@ pub trait ReadonlyIndex: Send + Sync { fn as_index(&self) -> &dyn Index; fn change_id_index(&self, heads: &mut dyn Iterator) - -> Box; + -> Box; fn start_modification(&self) -> Box; } diff --git a/lib/src/local_working_copy.rs b/lib/src/local_working_copy.rs index 3b44b2657..6e26e4477 100644 --- a/lib/src/local_working_copy.rs +++ b/lib/src/local_working_copy.rs @@ -35,10 +35,10 @@ use std::os::unix::fs::PermissionsExt as _; use std::path::Path; use std::path::PathBuf; use std::slice; -use std::sync::mpsc::channel; -use std::sync::mpsc::Sender; use std::sync::Arc; use std::sync::OnceLock; +use std::sync::mpsc::Sender; +use std::sync::mpsc::channel; use std::time::UNIX_EPOCH; use either::Either; @@ -70,24 +70,24 @@ use crate::backend::TreeValue; use crate::commit::Commit; use crate::config::ConfigGetError; use crate::conflicts; +use crate::conflicts::ConflictMarkerStyle; +use crate::conflicts::MIN_CONFLICT_MARKER_LEN; +use crate::conflicts::MaterializedTreeValue; use crate::conflicts::choose_materialized_conflict_marker_len; use crate::conflicts::materialize_merge_result_to_bytes_with_marker_len; use crate::conflicts::materialize_tree_value; -use crate::conflicts::ConflictMarkerStyle; -use crate::conflicts::MaterializedTreeValue; -use crate::conflicts::MIN_CONFLICT_MARKER_LEN; -use crate::eol::create_target_eol_strategy; pub use crate::eol::EolConversionMode; use crate::eol::TargetEolStrategy; +use crate::eol::create_target_eol_strategy; +use crate::file_util::BlockingAsyncReader; use crate::file_util::check_symlink_support; use crate::file_util::copy_async_to_sync; use crate::file_util::try_symlink; -use crate::file_util::BlockingAsyncReader; -#[cfg(feature = "watchman")] -use crate::fsmonitor::watchman; use crate::fsmonitor::FsmonitorSettings; #[cfg(feature = "watchman")] use crate::fsmonitor::WatchmanConfig; +#[cfg(feature = "watchman")] +use crate::fsmonitor::watchman; use crate::gitignore::GitIgnoreFile; use crate::lock::FileLock; use crate::matchers::DifferenceMatcher; @@ -610,7 +610,7 @@ fn create_parent_dirs( repo_path.to_fs_path_unchecked(working_copy_path).display(), ), err: err.into(), - }) + }); } }, }; @@ -679,7 +679,7 @@ fn can_create_new_file(disk_path: &Path) -> Result { return Err(CheckoutError::Other { message: format!("Failed to stat {}", disk_path.display()), err: err.into(), - }) + }); } }, }; diff --git a/lib/src/lock/fallback.rs b/lib/src/lock/fallback.rs index 875b935af..5f6344cbf 100644 --- a/lib/src/lock/fallback.rs +++ b/lib/src/lock/fallback.rs @@ -88,7 +88,7 @@ impl FileLock { message: "Failed to create lock file", path, err, - }) + }); } } } diff --git a/lib/src/merge.rs b/lib/src/merge.rs index 2d2afac6c..4c7651d06 100644 --- a/lib/src/merge.rs +++ b/lib/src/merge.rs @@ -28,8 +28,8 @@ use std::sync::Arc; use futures::future::try_join_all; use itertools::Itertools as _; -use smallvec::smallvec_inline; use smallvec::SmallVec; +use smallvec::smallvec_inline; use crate::backend; use crate::backend::BackendResult; diff --git a/lib/src/merged_tree.rs b/lib/src/merged_tree.rs index 82112069a..acb956bd1 100644 --- a/lib/src/merged_tree.rs +++ b/lib/src/merged_tree.rs @@ -21,17 +21,17 @@ use std::iter; use std::iter::zip; use std::pin::Pin; use std::sync::Arc; -use std::task::ready; use std::task::Context; use std::task::Poll; +use std::task::ready; use std::vec; use either::Either; -use futures::future::try_join; -use futures::future::BoxFuture; -use futures::stream::BoxStream; use futures::Stream; use futures::StreamExt as _; +use futures::future::BoxFuture; +use futures::future::try_join; +use futures::stream::BoxStream; use itertools::EitherOrBoth; use itertools::Itertools as _; use pollster::FutureExt as _; @@ -54,8 +54,8 @@ use crate::repo_path::RepoPath; use crate::repo_path::RepoPathBuf; use crate::repo_path::RepoPathComponent; use crate::store::Store; -use crate::tree::try_resolve_file_conflict; use crate::tree::Tree; +use crate::tree::try_resolve_file_conflict; use crate::tree_builder::TreeBuilder; /// Presents a view of a merged set of trees. @@ -75,10 +75,12 @@ impl MergedTree { pub fn new(trees: Merge) -> Self { debug_assert!(!trees.iter().any(|t| t.has_conflict())); debug_assert!(trees.iter().map(|tree| tree.dir()).all_equal()); - debug_assert!(trees - .iter() - .map(|tree| Arc::as_ptr(tree.store())) - .all_equal()); + debug_assert!( + trees + .iter() + .map(|tree| Arc::as_ptr(tree.store())) + .all_equal() + ); Self { trees } } @@ -1143,10 +1145,12 @@ impl MergedTreeBuilder { /// value or as a resolved `Merge` value using `TreeValue::Conflict`. pub fn set_or_remove(&mut self, path: RepoPathBuf, values: MergedTreeValue) { if let MergedTreeId::Merge(_) = &self.base_tree_id { - assert!(!values - .iter() - .flatten() - .any(|value| matches!(value, TreeValue::Conflict(_)))); + assert!( + !values + .iter() + .flatten() + .any(|value| matches!(value, TreeValue::Conflict(_))) + ); } self.overrides.insert(path, values); } diff --git a/lib/src/op_store.rs b/lib/src/op_store.rs index 0021d425e..6142a066b 100644 --- a/lib/src/op_store.rs +++ b/lib/src/op_store.rs @@ -31,10 +31,10 @@ use crate::backend::MillisSinceEpoch; use crate::backend::Timestamp; use crate::content_hash::ContentHash; use crate::merge::Merge; -use crate::object_id::id_type; use crate::object_id::HexPrefix; use crate::object_id::ObjectId as _; use crate::object_id::PrefixResolution; +use crate::object_id::id_type; use crate::ref_name::GitRefNameBuf; use crate::ref_name::RefName; use crate::ref_name::RefNameBuf; diff --git a/lib/src/ref_name.rs b/lib/src/ref_name.rs index a573dc509..1b8926e45 100644 --- a/lib/src/ref_name.rs +++ b/lib/src/ref_name.rs @@ -36,8 +36,8 @@ use std::fmt; use std::fmt::Display; use std::ops::Deref; -use ref_cast::ref_cast_custom; use ref_cast::RefCastCustom; +use ref_cast::ref_cast_custom; use crate::content_hash::ContentHash; use crate::revset; diff --git a/lib/src/refs.rs b/lib/src/refs.rs index 804ac6d2a..faf5d9c95 100644 --- a/lib/src/refs.rs +++ b/lib/src/refs.rs @@ -18,8 +18,8 @@ use itertools::EitherOrBoth; use crate::backend::CommitId; use crate::index::Index; -use crate::merge::trivial_merge; use crate::merge::Merge; +use crate::merge::trivial_merge; use crate::op_store::RefTarget; use crate::op_store::RemoteRef; diff --git a/lib/src/repo.rs b/lib/src/repo.rs index 0d117fb58..12e638f4a 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -14,10 +14,10 @@ #![allow(missing_docs)] -use std::collections::hash_map::Entry; use std::collections::BTreeMap; use std::collections::HashMap; use std::collections::HashSet; +use std::collections::hash_map::Entry; use std::fmt::Debug; use std::fmt::Formatter; use std::fs; @@ -56,8 +56,8 @@ use crate::index::IndexReadError; use crate::index::IndexStore; use crate::index::MutableIndex; use crate::index::ReadonlyIndex; -use crate::merge::trivial_merge; use crate::merge::MergeBuilder; +use crate::merge::trivial_merge; use crate::object_id::HexPrefix; use crate::object_id::PrefixResolution; use crate::op_heads_store; @@ -89,12 +89,12 @@ use crate::revset; use crate::revset::RevsetEvaluationError; use crate::revset::RevsetExpression; use crate::revset::RevsetIteratorExt as _; -use crate::rewrite::merge_commit_trees; -use crate::rewrite::rebase_commit_with_options; use crate::rewrite::CommitRewriter; use crate::rewrite::RebaseOptions; use crate::rewrite::RebasedCommit; use crate::rewrite::RewriteRefsOptions; +use crate::rewrite::merge_commit_trees; +use crate::rewrite::rebase_commit_with_options; use crate::settings::UserSettings; use crate::signing::SignInitError; use crate::signing::Signer; diff --git a/lib/src/repo_path.rs b/lib/src/repo_path.rs index 7a8fc3943..ccc22a6a1 100644 --- a/lib/src/repo_path.rs +++ b/lib/src/repo_path.rs @@ -26,8 +26,8 @@ use std::path::Path; use std::path::PathBuf; use itertools::Itertools as _; -use ref_cast::ref_cast_custom; use ref_cast::RefCastCustom; +use ref_cast::ref_cast_custom; use thiserror::Error; use crate::content_hash::ContentHash; @@ -939,18 +939,22 @@ mod tests { // Current/parent dir component assert!(repo_path(".").to_fs_path(Path::new("base")).is_err()); assert!(repo_path("..").to_fs_path(Path::new("base")).is_err()); - assert!(repo_path("dir/../file") - .to_fs_path(Path::new("base")) - .is_err()); + assert!( + repo_path("dir/../file") + .to_fs_path(Path::new("base")) + .is_err() + ); assert!(repo_path("./file").to_fs_path(Path::new("base")).is_err()); assert!(repo_path("file/.").to_fs_path(Path::new("base")).is_err()); assert!(repo_path("../file").to_fs_path(Path::new("base")).is_err()); assert!(repo_path("file/..").to_fs_path(Path::new("base")).is_err()); // Empty component (which is invalid as a repo path) - assert!(RepoPath::from_internal_string_unchecked("/") - .to_fs_path(Path::new("base")) - .is_err()); + assert!( + RepoPath::from_internal_string_unchecked("/") + .to_fs_path(Path::new("base")) + .is_err() + ); assert_eq!( // Iterator omits empty component after "/", which is fine so long // as the returned path doesn't escape. @@ -959,39 +963,57 @@ mod tests { .unwrap(), Path::new("base/a") ); - assert!(RepoPath::from_internal_string_unchecked("/b") - .to_fs_path(Path::new("base")) - .is_err()); - assert!(RepoPath::from_internal_string_unchecked("a//b") - .to_fs_path(Path::new("base")) - .is_err()); + assert!( + RepoPath::from_internal_string_unchecked("/b") + .to_fs_path(Path::new("base")) + .is_err() + ); + assert!( + RepoPath::from_internal_string_unchecked("a//b") + .to_fs_path(Path::new("base")) + .is_err() + ); // Component containing slash (simulating Windows path separator) - assert!(RepoPathComponent::new_unchecked("wind/ows") - .to_fs_name() - .is_err()); - assert!(RepoPathComponent::new_unchecked("./file") - .to_fs_name() - .is_err()); - assert!(RepoPathComponent::new_unchecked("file/.") - .to_fs_name() - .is_err()); + assert!( + RepoPathComponent::new_unchecked("wind/ows") + .to_fs_name() + .is_err() + ); + assert!( + RepoPathComponent::new_unchecked("./file") + .to_fs_name() + .is_err() + ); + assert!( + RepoPathComponent::new_unchecked("file/.") + .to_fs_name() + .is_err() + ); assert!(RepoPathComponent::new_unchecked("/").to_fs_name().is_err()); // Windows path separator and drive letter if cfg!(windows) { - assert!(repo_path(r#"wind\ows"#) - .to_fs_path(Path::new("base")) - .is_err()); - assert!(repo_path(r#".\file"#) - .to_fs_path(Path::new("base")) - .is_err()); - assert!(repo_path(r#"file\."#) - .to_fs_path(Path::new("base")) - .is_err()); - assert!(repo_path(r#"c:/foo"#) - .to_fs_path(Path::new("base")) - .is_err()); + assert!( + repo_path(r#"wind\ows"#) + .to_fs_path(Path::new("base")) + .is_err() + ); + assert!( + repo_path(r#".\file"#) + .to_fs_path(Path::new("base")) + .is_err() + ); + assert!( + repo_path(r#"file\."#) + .to_fs_path(Path::new("base")) + .is_err() + ); + assert!( + repo_path(r#"c:/foo"#) + .to_fs_path(Path::new("base")) + .is_err() + ); } } diff --git a/lib/src/revset.rs b/lib/src/revset.rs index 0ce4c6cf5..00078cf19 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -15,8 +15,8 @@ #![allow(missing_docs)] use std::any::Any; -use std::collections::hash_map; use std::collections::HashMap; +use std::collections::hash_map; use std::convert::Infallible; use std::fmt; use std::ops::ControlFlow; @@ -54,9 +54,6 @@ use crate::repo::Repo; use crate::repo::RepoLoaderError; use crate::repo_path::RepoPathUiConverter; use crate::revset_parser; -pub use crate::revset_parser::expect_literal; -pub use crate::revset_parser::parse_program; -pub use crate::revset_parser::parse_symbol; pub use crate::revset_parser::BinaryOp; pub use crate::revset_parser::ExpressionKind; pub use crate::revset_parser::ExpressionNode; @@ -66,6 +63,9 @@ pub use crate::revset_parser::RevsetDiagnostics; pub use crate::revset_parser::RevsetParseError; pub use crate::revset_parser::RevsetParseErrorKind; pub use crate::revset_parser::UnaryOp; +pub use crate::revset_parser::expect_literal; +pub use crate::revset_parser::parse_program; +pub use crate::revset_parser::parse_symbol; use crate::store::Store; use crate::str_util::StringPattern; use crate::time_util::DatePattern; diff --git a/lib/src/revset_parser.rs b/lib/src/revset_parser.rs index c80ced526..caa4d4d0a 100644 --- a/lib/src/revset_parser.rs +++ b/lib/src/revset_parser.rs @@ -21,17 +21,16 @@ use std::str::FromStr; use std::sync::LazyLock; use itertools::Itertools as _; +use pest::Parser as _; use pest::iterators::Pair; use pest::iterators::Pairs; use pest::pratt_parser::Assoc; use pest::pratt_parser::Op; use pest::pratt_parser::PrattParser; -use pest::Parser as _; use pest_derive::Parser; use thiserror::Error; use crate::dsl_util; -use crate::dsl_util::collect_similar; use crate::dsl_util::AliasDeclaration; use crate::dsl_util::AliasDeclarationParser; use crate::dsl_util::AliasDefinitionParser; @@ -45,6 +44,7 @@ use crate::dsl_util::FoldableExpression; use crate::dsl_util::FunctionCallParser; use crate::dsl_util::InvalidArguments; use crate::dsl_util::StringLiteralParser; +use crate::dsl_util::collect_similar; use crate::ref_name::RefNameBuf; use crate::ref_name::RemoteNameBuf; use crate::ref_name::RemoteRefSymbolBuf; diff --git a/lib/src/rewrite.rs b/lib/src/rewrite.rs index 981fab75b..f00c58073 100644 --- a/lib/src/rewrite.rs +++ b/lib/src/rewrite.rs @@ -19,9 +19,9 @@ use std::collections::HashSet; use std::slice; use std::sync::Arc; +use futures::StreamExt as _; use futures::future::try_join_all; use futures::try_join; -use futures::StreamExt as _; use indexmap::IndexMap; use indexmap::IndexSet; use itertools::Itertools as _; diff --git a/lib/src/simple_backend.rs b/lib/src/simple_backend.rs index bab66f387..fb3893aa3 100644 --- a/lib/src/simple_backend.rs +++ b/lib/src/simple_backend.rs @@ -37,7 +37,6 @@ use tempfile::NamedTempFile; use tokio::io::AsyncRead; use tokio::io::AsyncReadExt as _; -use crate::backend::make_root_commit; use crate::backend::Backend; use crate::backend::BackendError; use crate::backend::BackendResult; @@ -61,6 +60,7 @@ use crate::backend::Timestamp; use crate::backend::Tree; use crate::backend::TreeId; use crate::backend::TreeValue; +use crate::backend::make_root_commit; use crate::content_hash::blake2b_hash; use crate::file_util::persist_content_addressed_temp_file; use crate::index::Index; diff --git a/lib/src/simple_op_store.rs b/lib/src/simple_op_store.rs index 7ab778385..6ab07b505 100644 --- a/lib/src/simple_op_store.rs +++ b/lib/src/simple_op_store.rs @@ -38,9 +38,9 @@ use crate::backend::MillisSinceEpoch; use crate::backend::Timestamp; use crate::content_hash::blake2b_hash; use crate::dag_walk; -use crate::file_util::persist_content_addressed_temp_file; use crate::file_util::IoResultExt as _; use crate::file_util::PathError; +use crate::file_util::persist_content_addressed_temp_file; use crate::merge::Merge; use crate::object_id::HexPrefix; use crate::object_id::ObjectId; diff --git a/lib/src/str_util.rs b/lib/src/str_util.rs index 3b1fd3435..31308f49a 100644 --- a/lib/src/str_util.rs +++ b/lib/src/str_util.rs @@ -476,11 +476,15 @@ mod tests { assert!(StringPattern::regex(r"^.$").unwrap().is_match("\u{c0}")); // ASCII-compatible mode should also work assert!(StringPattern::regex(r"^(?-u)\w$").unwrap().is_match("a")); - assert!(!StringPattern::regex(r"^(?-u)\w$") - .unwrap() - .is_match("\u{c0}")); - assert!(StringPattern::regex(r"^(?-u).{2}$") - .unwrap() - .is_match("\u{c0}")); + assert!( + !StringPattern::regex(r"^(?-u)\w$") + .unwrap() + .is_match("\u{c0}") + ); + assert!( + StringPattern::regex(r"^(?-u).{2}$") + .unwrap() + .is_match("\u{c0}") + ); } } diff --git a/lib/src/time_util.rs b/lib/src/time_util.rs index 50303e689..d925fde6e 100644 --- a/lib/src/time_util.rs +++ b/lib/src/time_util.rs @@ -18,9 +18,9 @@ use chrono::DateTime; use chrono::FixedOffset; use chrono::Local; use chrono::TimeZone; -use interim::parse_date_string; use interim::DateError; use interim::Dialect; +use interim::parse_date_string; use thiserror::Error; use crate::backend::MillisSinceEpoch; diff --git a/lib/src/union_find.rs b/lib/src/union_find.rs index b1778827e..df967aa82 100644 --- a/lib/src/union_find.rs +++ b/lib/src/union_find.rs @@ -121,14 +121,16 @@ mod tests { // Unioning the pairs gives everything the same root. union_find.union(1, 3); - assert!([ - union_find.find(1), - union_find.find(2), - union_find.find(3), - union_find.find(4), - ] - .iter() - .all_equal()); + assert!( + [ + union_find.find(1), + union_find.find(2), + union_find.find(3), + union_find.find(4), + ] + .iter() + .all_equal() + ); } #[test] diff --git a/lib/src/workspace.rs b/lib/src/workspace.rs index c7641fbb3..5239cecc7 100644 --- a/lib/src/workspace.rs +++ b/lib/src/workspace.rs @@ -36,7 +36,6 @@ use crate::op_heads_store::OpHeadsStoreError; use crate::op_store::OperationId; use crate::ref_name::WorkspaceName; use crate::ref_name::WorkspaceNameBuf; -use crate::repo::read_store_type; use crate::repo::BackendInitializer; use crate::repo::CheckOutCommitError; use crate::repo::IndexStoreInitializer; @@ -49,6 +48,7 @@ use crate::repo::RepoLoader; use crate::repo::StoreFactories; use crate::repo::StoreLoadError; use crate::repo::SubmoduleStoreInitializer; +use crate::repo::read_store_type; use crate::settings::UserSettings; use crate::signing::SignInitError; use crate::signing::Signer; @@ -478,7 +478,7 @@ impl LockedWorkspace<'_> { // Factory trait to build WorkspaceLoaders given the workspace root. pub trait WorkspaceLoaderFactory { fn create(&self, workspace_root: &Path) - -> Result, WorkspaceLoadError>; + -> Result, WorkspaceLoadError>; } pub fn get_working_copy_factory<'a>( diff --git a/lib/tests/test_annotate.rs b/lib/tests/test_annotate.rs index 916d50bc6..8f846c6af 100644 --- a/lib/tests/test_annotate.rs +++ b/lib/tests/test_annotate.rs @@ -30,10 +30,10 @@ use jj_lib::repo::Repo; use jj_lib::repo_path::RepoPath; use jj_lib::revset::ResolvedRevsetExpression; use jj_lib::revset::RevsetExpression; +use testutils::TestRepo; use testutils::create_tree; use testutils::read_file; use testutils::repo_path; -use testutils::TestRepo; fn create_commit_fn( mut_repo: &mut MutableRepo, diff --git a/lib/tests/test_bad_locking.rs b/lib/tests/test_bad_locking.rs index 8b20c1cde..a3e002636 100644 --- a/lib/tests/test_bad_locking.rs +++ b/lib/tests/test_bad_locking.rs @@ -17,12 +17,12 @@ use std::path::Path; use itertools::Itertools as _; use jj_lib::repo::Repo as _; use jj_lib::repo::StoreFactories; -use jj_lib::workspace::default_working_copy_factories; use jj_lib::workspace::Workspace; +use jj_lib::workspace::default_working_copy_factories; use test_case::test_case; -use testutils::create_random_commit; use testutils::TestRepoBackend; use testutils::TestWorkspace; +use testutils::create_random_commit; fn copy_directory(src: &Path, dst: &Path) { std::fs::create_dir(dst).ok(); diff --git a/lib/tests/test_commit_builder.rs b/lib/tests/test_commit_builder.rs index 1743ed409..c19f25a37 100644 --- a/lib/tests/test_commit_builder.rs +++ b/lib/tests/test_commit_builder.rs @@ -33,13 +33,13 @@ use jj_lib::rewrite::RebaseOptions; use jj_lib::settings::UserSettings; use pollster::FutureExt as _; use test_case::test_case; +use testutils::CommitGraphBuilder; +use testutils::TestRepo; +use testutils::TestRepoBackend; use testutils::assert_rebased_onto; use testutils::create_tree; use testutils::rebase_descendants_with_options_return_map; use testutils::repo_path; -use testutils::CommitGraphBuilder; -use testutils::TestRepo; -use testutils::TestRepoBackend; fn config_with_commit_timestamp(timestamp: &str) -> StackedConfig { let mut config = testutils::base_user_config(); diff --git a/lib/tests/test_commit_concurrent.rs b/lib/tests/test_commit_concurrent.rs index 4d7a8689b..f498f65e5 100644 --- a/lib/tests/test_commit_concurrent.rs +++ b/lib/tests/test_commit_concurrent.rs @@ -20,9 +20,9 @@ use jj_lib::dag_walk; use jj_lib::repo::ReadonlyRepo; use jj_lib::repo::Repo as _; use test_case::test_case; -use testutils::write_random_commit; use testutils::TestRepoBackend; use testutils::TestWorkspace; +use testutils::write_random_commit; fn count_non_merge_operations(repo: &Arc) -> usize { let op_store = repo.op_store(); diff --git a/lib/tests/test_conflicts.rs b/lib/tests/test_conflicts.rs index c28797076..ffcba4754 100644 --- a/lib/tests/test_conflicts.rs +++ b/lib/tests/test_conflicts.rs @@ -15,21 +15,21 @@ use indoc::indoc; use itertools::Itertools as _; use jj_lib::backend::FileId; +use jj_lib::conflicts::ConflictMarkerStyle; +use jj_lib::conflicts::MIN_CONFLICT_MARKER_LEN; use jj_lib::conflicts::choose_materialized_conflict_marker_len; use jj_lib::conflicts::extract_as_single_hunk; use jj_lib::conflicts::materialize_merge_result_to_bytes; use jj_lib::conflicts::parse_conflict; use jj_lib::conflicts::update_from_content; -use jj_lib::conflicts::ConflictMarkerStyle; -use jj_lib::conflicts::MIN_CONFLICT_MARKER_LEN; use jj_lib::merge::Merge; use jj_lib::repo::Repo as _; use jj_lib::repo_path::RepoPath; use jj_lib::store::Store; use pollster::FutureExt as _; +use testutils::TestRepo; use testutils::read_file; use testutils::repo_path; -use testutils::TestRepo; #[test] fn test_materialize_conflict_basic() { diff --git a/lib/tests/test_eol.rs b/lib/tests/test_eol.rs index 1758cb767..453a513e2 100644 --- a/lib/tests/test_eol.rs +++ b/lib/tests/test_eol.rs @@ -23,15 +23,15 @@ use jj_lib::repo::StoreFactories; use jj_lib::rewrite::merge_commit_trees; use jj_lib::settings::UserSettings; use jj_lib::working_copy::CheckoutOptions; -use jj_lib::workspace::default_working_copy_factories; use jj_lib::workspace::Workspace; +use jj_lib::workspace::default_working_copy_factories; use pollster::FutureExt as _; use test_case::test_case; +use testutils::TestRepoBackend; +use testutils::TestWorkspace; use testutils::base_user_config; use testutils::commit_with_tree; use testutils::repo_path; -use testutils::TestRepoBackend; -use testutils::TestWorkspace; static LF_FILE_CONTENT: &[u8] = b"aaa\nbbbb\nccccc\n"; static CRLF_FILE_CONTENT: &[u8] = b"aaa\r\nbbbb\r\nccccc\r\n"; diff --git a/lib/tests/test_evolution_predecessors.rs b/lib/tests/test_evolution_predecessors.rs index a97fbc579..ffbe52bb8 100644 --- a/lib/tests/test_evolution_predecessors.rs +++ b/lib/tests/test_evolution_predecessors.rs @@ -20,18 +20,18 @@ use jj_lib::backend::CommitId; use jj_lib::commit::Commit; use jj_lib::config::ConfigLayer; use jj_lib::config::ConfigSource; -use jj_lib::evolution::accumulate_predecessors; -use jj_lib::evolution::walk_predecessors; use jj_lib::evolution::CommitEvolutionEntry; use jj_lib::evolution::WalkPredecessorsError; +use jj_lib::evolution::accumulate_predecessors; +use jj_lib::evolution::walk_predecessors; use jj_lib::repo::MutableRepo; use jj_lib::repo::ReadonlyRepo; use jj_lib::repo::Repo as _; use jj_lib::settings::UserSettings; use maplit::btreemap; +use testutils::TestRepo; use testutils::commit_transactions; use testutils::write_random_commit; -use testutils::TestRepo; fn collect_predecessors(repo: &ReadonlyRepo, start_commit: &CommitId) -> Vec { walk_predecessors(repo, slice::from_ref(start_commit)) diff --git a/lib/tests/test_fix.rs b/lib/tests/test_fix.rs index edd83675e..ca9e6f6bc 100644 --- a/lib/tests/test_fix.rs +++ b/lib/tests/test_fix.rs @@ -18,21 +18,21 @@ use std::collections::HashSet; use jj_lib::backend::CommitId; use jj_lib::backend::FileId; use jj_lib::backend::MergedTreeId; -use jj_lib::fix::fix_files; use jj_lib::fix::FileFixer; use jj_lib::fix::FileToFix; use jj_lib::fix::FixError; use jj_lib::fix::ParallelFileFixer; +use jj_lib::fix::fix_files; use jj_lib::matchers::EverythingMatcher; use jj_lib::repo::Repo as _; use jj_lib::store::Store; use jj_lib::transaction::Transaction; use pollster::FutureExt as _; +use testutils::TestRepo; use testutils::create_tree; use testutils::create_tree_with; use testutils::read_file; use testutils::repo_path; -use testutils::TestRepo; use thiserror::Error; struct TestFileFixer {} diff --git a/lib/tests/test_git.rs b/lib/tests/test_git.rs index fe219e149..5aff56f85 100644 --- a/lib/tests/test_git.rs +++ b/lib/tests/test_git.rs @@ -19,9 +19,9 @@ use std::io::Write as _; use std::iter; use std::path::Path; use std::path::PathBuf; -use std::sync::mpsc; use std::sync::Arc; use std::sync::Barrier; +use std::sync::mpsc; use std::thread; use assert_matches::assert_matches; @@ -72,14 +72,14 @@ use maplit::btreemap; use maplit::hashset; use tempfile::TempDir; use test_case::test_case; +use testutils::CommitGraphBuilder; +use testutils::TestRepo; +use testutils::TestRepoBackend; use testutils::base_user_config; use testutils::commit_transactions; use testutils::create_random_commit; use testutils::repo_path; use testutils::write_random_commit; -use testutils::CommitGraphBuilder; -use testutils::TestRepo; -use testutils::TestRepoBackend; /// Describes successful `fetch()` result. #[derive(Clone, Debug, Eq, PartialEq, Default)] @@ -237,9 +237,10 @@ fn test_import_refs() { state: RemoteRefState::Tracked, }, ); - assert!(view - .get_remote_bookmark(remote_symbol("feature1", "origin")) - .is_absent()); + assert!( + view.get_remote_bookmark(remote_symbol("feature1", "origin")) + .is_absent() + ); assert_eq!( view.get_local_bookmark("feature2".as_ref()), &RefTarget::normal(jj_id(commit4)) @@ -251,16 +252,18 @@ fn test_import_refs() { state: RemoteRefState::Tracked, }, ); - assert!(view - .get_remote_bookmark(remote_symbol("feature2", "origin")) - .is_absent()); + assert!( + view.get_remote_bookmark(remote_symbol("feature2", "origin")) + .is_absent() + ); assert_eq!( view.get_local_bookmark("feature3".as_ref()), &RefTarget::normal(jj_id(commit6)) ); - assert!(view - .get_remote_bookmark(remote_symbol("feature3", "git")) - .is_absent()); + assert!( + view.get_remote_bookmark(remote_symbol("feature3", "git")) + .is_absent() + ); assert_eq!( view.get_remote_bookmark(remote_symbol("feature3", "origin")), &RemoteRef { @@ -407,9 +410,10 @@ fn test_import_refs_reimport() { state: RemoteRefState::Tracked, }, ); - assert!(view - .get_remote_bookmark(remote_symbol("feature2", "origin")) - .is_absent()); + assert!( + view.get_remote_bookmark(remote_symbol("feature2", "origin")) + .is_absent() + ); assert!(view.tags().is_empty()); @@ -619,9 +623,10 @@ fn test_import_refs_reimport_with_deleted_remote_ref() { view.get_local_bookmark("feature-remote-only".as_ref()), &RefTarget::normal(jj_id(commit_remote_only)) ); - assert!(view - .get_remote_bookmark(remote_symbol("feature-remote-only", "git")) - .is_absent()); + assert!( + view.get_remote_bookmark(remote_symbol("feature-remote-only", "git")) + .is_absent() + ); assert_eq!( view.get_remote_bookmark(remote_symbol("feature-remote-only", "origin")), &RemoteRef { @@ -664,15 +669,18 @@ fn test_import_refs_reimport_with_deleted_remote_ref() { // The local bookmarks were indeed deleted assert_eq!(view.bookmarks().count(), 2); assert!(view.get_local_bookmark("main".as_ref()).is_present()); - assert!(view - .get_local_bookmark("feature-remote-only".as_ref()) - .is_absent()); - assert!(view - .get_remote_bookmark(remote_symbol("feature-remote-only", "origin")) - .is_absent()); - assert!(view - .get_local_bookmark("feature-remote-and-local".as_ref()) - .is_absent()); + assert!( + view.get_local_bookmark("feature-remote-only".as_ref()) + .is_absent() + ); + assert!( + view.get_remote_bookmark(remote_symbol("feature-remote-only", "origin")) + .is_absent() + ); + assert!( + view.get_local_bookmark("feature-remote-and-local".as_ref()) + .is_absent() + ); assert_eq!( view.get_remote_bookmark(remote_symbol("feature-remote-and-local", "git")), &RemoteRef { @@ -680,9 +688,10 @@ fn test_import_refs_reimport_with_deleted_remote_ref() { state: RemoteRefState::Tracked, }, ); - assert!(view - .get_remote_bookmark(remote_symbol("feature-remote-and-local", "origin")) - .is_absent()); + assert!( + view.get_remote_bookmark(remote_symbol("feature-remote-and-local", "origin")) + .is_absent() + ); let expected_heads = hashset! { jj_id(commit_main), // Neither commit_remote_only nor commit_remote_and_local should be @@ -742,9 +751,10 @@ fn test_import_refs_reimport_with_moved_remote_ref() { view.get_local_bookmark("feature-remote-only".as_ref()), &RefTarget::normal(jj_id(commit_remote_only)) ); - assert!(view - .get_remote_bookmark(remote_symbol("feature-remote-only", "git")) - .is_absent()); + assert!( + view.get_remote_bookmark(remote_symbol("feature-remote-only", "git")) + .is_absent() + ); assert_eq!( view.get_remote_bookmark(remote_symbol("feature-remote-only", "origin")), &RemoteRef { @@ -800,9 +810,10 @@ fn test_import_refs_reimport_with_moved_remote_ref() { view.get_local_bookmark("feature-remote-only".as_ref()), &RefTarget::normal(jj_id(new_commit_remote_only)) ); - assert!(view - .get_remote_bookmark(remote_symbol("feature-remote-only", "git")) - .is_absent()); + assert!( + view.get_remote_bookmark(remote_symbol("feature-remote-only", "git")) + .is_absent() + ); assert_eq!( view.get_remote_bookmark(remote_symbol("feature-remote-only", "origin")), &RemoteRef { @@ -1305,20 +1316,24 @@ fn test_import_some_refs() { &commit_feat4_remote_ref ); assert!(view.get_local_bookmark("main".as_ref()).is_absent()); - assert!(view - .get_remote_bookmark(remote_symbol("main", "git")) - .is_absent()); - assert!(view - .get_remote_bookmark(remote_symbol("main", "origin")) - .is_absent()); + assert!( + view.get_remote_bookmark(remote_symbol("main", "git")) + .is_absent() + ); + assert!( + view.get_remote_bookmark(remote_symbol("main", "origin")) + .is_absent() + ); assert!(!view.heads().contains(&jj_id(commit_main))); assert!(view.get_local_bookmark("ignored".as_ref()).is_absent()); - assert!(view - .get_remote_bookmark(remote_symbol("ignored", "git")) - .is_absent()); - assert!(view - .get_remote_bookmark(remote_symbol("ignored", "origin")) - .is_absent()); + assert!( + view.get_remote_bookmark(remote_symbol("ignored", "git")) + .is_absent() + ); + assert!( + view.get_remote_bookmark(remote_symbol("ignored", "origin")) + .is_absent() + ); assert!(!view.heads().contains(&jj_id(commit_ign))); // Delete bookmark feature1, feature3 and feature4 in git repository and import @@ -1826,10 +1841,12 @@ fn test_import_export_non_tracking_bookmark() { git::import_refs(mut_repo, &git_settings).unwrap(); - assert!(mut_repo - .view() - .get_local_bookmark("main".as_ref()) - .is_absent()); + assert!( + mut_repo + .view() + .get_local_bookmark("main".as_ref()) + .is_absent() + ); assert_eq!( mut_repo .view() @@ -1858,10 +1875,12 @@ fn test_import_export_non_tracking_bookmark() { let commit_feat_t1 = empty_git_commit(&git_repo, "refs/remotes/origin/feat", &[]); git_settings.auto_local_bookmark = true; git::import_refs(mut_repo, &git_settings).unwrap(); - assert!(mut_repo - .view() - .get_local_bookmark("main".as_ref()) - .is_absent()); + assert!( + mut_repo + .view() + .get_local_bookmark("main".as_ref()) + .is_absent() + ); assert_eq!( mut_repo.view().get_local_bookmark("feat".as_ref()), &RefTarget::normal(jj_id(commit_feat_t1)) @@ -1890,10 +1909,12 @@ fn test_import_export_non_tracking_bookmark() { let commit_feat_t2 = empty_git_commit(&git_repo, "refs/remotes/origin/feat", &[commit_feat_t1]); git_settings.auto_local_bookmark = false; git::import_refs(mut_repo, &git_settings).unwrap(); - assert!(mut_repo - .view() - .get_local_bookmark("main".as_ref()) - .is_absent()); + assert!( + mut_repo + .view() + .get_local_bookmark("main".as_ref()) + .is_absent() + ); assert_eq!( mut_repo.view().get_local_bookmark("feat".as_ref()), &RefTarget::normal(jj_id(commit_feat_t2)) @@ -2060,12 +2081,16 @@ fn test_export_partial_failure() { assert!(git_repo.find_reference("refs/heads/main/sub").is_err()); // Failed bookmarks shouldn't be copied to the "git" remote - assert!(mut_repo - .get_remote_bookmark(remote_symbol("", "git")) - .is_absent()); - assert!(mut_repo - .get_remote_bookmark(remote_symbol("HEAD", "git")) - .is_absent()); + assert!( + mut_repo + .get_remote_bookmark(remote_symbol("", "git")) + .is_absent() + ); + assert!( + mut_repo + .get_remote_bookmark(remote_symbol("HEAD", "git")) + .is_absent() + ); assert_eq!( mut_repo.get_remote_bookmark(remote_symbol("main", "git")), RemoteRef { @@ -2073,9 +2098,11 @@ fn test_export_partial_failure() { state: RemoteRefState::Tracked, }, ); - assert!(mut_repo - .get_remote_bookmark(remote_symbol("main/sub", "git")) - .is_absent()); + assert!( + mut_repo + .get_remote_bookmark(remote_symbol("main/sub", "git")) + .is_absent() + ); // Now remove the `main` bookmark and make sure that the `main/sub` gets // exported even though it didn't change @@ -2111,15 +2138,21 @@ fn test_export_partial_failure() { ); // Failed bookmarks shouldn't be copied to the "git" remote - assert!(mut_repo - .get_remote_bookmark(remote_symbol("", "git")) - .is_absent()); - assert!(mut_repo - .get_remote_bookmark(remote_symbol("HEAD", "git")) - .is_absent()); - assert!(mut_repo - .get_remote_bookmark(remote_symbol("main", "git")) - .is_absent()); + assert!( + mut_repo + .get_remote_bookmark(remote_symbol("", "git")) + .is_absent() + ); + assert!( + mut_repo + .get_remote_bookmark(remote_symbol("HEAD", "git")) + .is_absent() + ); + assert!( + mut_repo + .get_remote_bookmark(remote_symbol("main", "git")) + .is_absent() + ); assert_eq!( mut_repo.get_remote_bookmark(remote_symbol("main/sub", "git")), RemoteRef { @@ -2992,10 +3025,11 @@ fn test_fetch_prune_deleted_ref() { .unwrap(); // Test the setup assert!(tx.repo().get_local_bookmark("main".as_ref()).is_present()); - assert!(tx - .repo() - .get_remote_bookmark(remote_symbol("main", "origin")) - .is_present()); + assert!( + tx.repo() + .get_remote_bookmark(remote_symbol("main", "origin")) + .is_present() + ); test_data .origin_repo @@ -3013,10 +3047,11 @@ fn test_fetch_prune_deleted_ref() { .unwrap(); assert_eq!(stats.import_stats.abandoned_commits, vec![jj_id(commit)]); assert!(tx.repo().get_local_bookmark("main".as_ref()).is_absent()); - assert!(tx - .repo_mut() - .get_remote_bookmark(remote_symbol("main", "origin")) - .is_absent()); + assert!( + tx.repo_mut() + .get_remote_bookmark(remote_symbol("main", "origin")) + .is_absent() + ); } #[test] @@ -3067,16 +3102,18 @@ fn test_fetch_empty_refspecs() { // Base refspecs shouldn't be respected let mut tx = test_data.repo.start_transaction(); git_fetch(tx.repo_mut(), "origin".as_ref(), &[], &git_settings).unwrap(); - assert!(tx - .repo_mut() - .get_remote_bookmark(remote_symbol("main", "origin")) - .is_absent()); + assert!( + tx.repo_mut() + .get_remote_bookmark(remote_symbol("main", "origin")) + .is_absent() + ); // No remote refs should have been fetched git::import_refs(tx.repo_mut(), &git_settings).unwrap(); - assert!(tx - .repo_mut() - .get_remote_bookmark(remote_symbol("main", "origin")) - .is_absent()); + assert!( + tx.repo_mut() + .get_remote_bookmark(remote_symbol("main", "origin")) + .is_absent() + ); } #[test] @@ -3329,18 +3366,22 @@ fn test_push_bookmarks_deletion() { // Check that the ref got deleted in the cloned repo. This just tests our // assumptions about libgit2 because we want the refs/remotes/origin/main // bookmark to be deleted. - assert!(clone_repo - .find_reference("refs/remotes/origin/main") - .is_err()); + assert!( + clone_repo + .find_reference("refs/remotes/origin/main") + .is_err() + ); // Check that the repo view got updated let view = tx.repo().view(); - assert!(view - .get_git_ref("refs/remotes/origin/main".as_ref()) - .is_absent()); - assert!(view - .get_remote_bookmark(remote_symbol("main", "origin")) - .is_absent()); + assert!( + view.get_git_ref("refs/remotes/origin/main".as_ref()) + .is_absent() + ); + assert!( + view.get_remote_bookmark(remote_symbol("main", "origin")) + .is_absent() + ); // Check that the repo view reflects the changes in the Git repo setup.jj_repo = tx.commit("test").unwrap(); @@ -3403,12 +3444,14 @@ fn test_push_bookmarks_mixed_deletion_and_addition() { // Check that the repo view got updated let view = tx.repo().view(); - assert!(view - .get_git_ref("refs/remotes/origin/main".as_ref()) - .is_absent()); - assert!(view - .get_remote_bookmark(remote_symbol("main", "origin")) - .is_absent()); + assert!( + view.get_git_ref("refs/remotes/origin/main".as_ref()) + .is_absent() + ); + assert!( + view.get_remote_bookmark(remote_symbol("main", "origin")) + .is_absent() + ); assert_eq!( *view.get_git_ref("refs/remotes/origin/topic".as_ref()), RefTarget::normal(setup.child_of_main_commit.id().clone()), @@ -4165,14 +4208,18 @@ fn test_remote_remove_refs() { let repo = &tx.commit("remove").unwrap(); let git_repo = get_git_repo(repo); - assert!(git_repo - .try_find_reference("refs/remotes/foo/a") - .unwrap() - .is_none()); - assert!(git_repo - .try_find_reference("refs/remotes/foo/x/y") - .unwrap() - .is_none()); + assert!( + git_repo + .try_find_reference("refs/remotes/foo/a") + .unwrap() + .is_none() + ); + assert!( + git_repo + .try_find_reference("refs/remotes/foo/x/y") + .unwrap() + .is_none() + ); assert_eq!( git_repo .find_reference("refs/remotes/foobar/a") @@ -4203,14 +4250,18 @@ fn test_remote_rename_refs() { let repo = &tx.commit("rename").unwrap(); let git_repo = get_git_repo(repo); - assert!(git_repo - .try_find_reference("refs/remotes/foo/a") - .unwrap() - .is_none()); - assert!(git_repo - .try_find_reference("refs/remotes/foo/x/y") - .unwrap() - .is_none()); + assert!( + git_repo + .try_find_reference("refs/remotes/foo/a") + .unwrap() + .is_none() + ); + assert!( + git_repo + .try_find_reference("refs/remotes/foo/x/y") + .unwrap() + .is_none() + ); assert_eq!( git_repo.find_reference("refs/remotes/bar/a").unwrap().id(), commit_foo_a, diff --git a/lib/tests/test_git_backend.rs b/lib/tests/test_git_backend.rs index a09f43dc6..9afeb3d47 100644 --- a/lib/tests/test_git_backend.rs +++ b/lib/tests/test_git_backend.rs @@ -34,6 +34,9 @@ use jj_lib::store::Store; use jj_lib::transaction::Transaction; use maplit::hashmap; use maplit::hashset; +use testutils::CommitGraphBuilder; +use testutils::TestRepo; +use testutils::TestRepoBackend; use testutils::commit_with_tree; use testutils::create_random_commit; use testutils::create_single_tree; @@ -41,9 +44,6 @@ use testutils::create_tree; use testutils::is_external_tool_installed; use testutils::repo_path; use testutils::repo_path_buf; -use testutils::CommitGraphBuilder; -use testutils::TestRepo; -use testutils::TestRepoBackend; fn get_git_backend(repo: &Arc) -> &GitBackend { repo.store() diff --git a/lib/tests/test_index.rs b/lib/tests/test_index.rs index c74023a3d..47a549b21 100644 --- a/lib/tests/test_index.rs +++ b/lib/tests/test_index.rs @@ -37,15 +37,15 @@ use jj_lib::ref_name::RemoteRefSymbol; use jj_lib::repo::MutableRepo; use jj_lib::repo::ReadonlyRepo; use jj_lib::repo::Repo as _; -use jj_lib::revset::ResolvedExpression; use jj_lib::revset::GENERATION_RANGE_FULL; +use jj_lib::revset::ResolvedExpression; use maplit::hashset; +use testutils::CommitGraphBuilder; +use testutils::TestRepo; use testutils::commit_transactions; use testutils::create_random_commit; use testutils::test_backend::TestBackend; use testutils::write_random_commit; -use testutils::CommitGraphBuilder; -use testutils::TestRepo; fn child_commit<'repo>(mut_repo: &'repo mut MutableRepo, commit: &Commit) -> CommitBuilder<'repo> { create_random_commit(mut_repo).set_parents(vec![commit.id().clone()]) diff --git a/lib/tests/test_init.rs b/lib/tests/test_init.rs index 56e490301..b22e3c2eb 100644 --- a/lib/tests/test_init.rs +++ b/lib/tests/test_init.rs @@ -23,10 +23,10 @@ use jj_lib::repo::Repo as _; use jj_lib::settings::UserSettings; use jj_lib::workspace::Workspace; use test_case::test_case; -use testutils::git; -use testutils::write_random_commit; use testutils::TestRepoBackend; use testutils::TestWorkspace; +use testutils::git; +use testutils::write_random_commit; fn canonicalize(input: &Path) -> (PathBuf, PathBuf) { let uncanonical = input.join("..").join(input.file_name().unwrap()); @@ -40,11 +40,12 @@ fn test_init_local() { let temp_dir = testutils::new_temp_dir(); let (canonical, uncanonical) = canonicalize(temp_dir.path()); let (workspace, repo) = Workspace::init_simple(&settings, &uncanonical).unwrap(); - assert!(repo - .store() - .backend_impl() - .downcast_ref::() - .is_none()); + assert!( + repo.store() + .backend_impl() + .downcast_ref::() + .is_none() + ); assert_eq!(workspace.workspace_root(), &canonical); // Just test that we can write a commit to the store diff --git a/lib/tests/test_load_repo.rs b/lib/tests/test_load_repo.rs index 66ac7912c..af13379e8 100644 --- a/lib/tests/test_load_repo.rs +++ b/lib/tests/test_load_repo.rs @@ -13,8 +13,8 @@ // limitations under the License. use jj_lib::repo::RepoLoader; -use testutils::write_random_commit; use testutils::TestRepo; +use testutils::write_random_commit; #[test] fn test_load_at_operation() { diff --git a/lib/tests/test_local_working_copy.rs b/lib/tests/test_local_working_copy.rs index 3a37c42d0..766a64c1a 100644 --- a/lib/tests/test_local_working_copy.rs +++ b/lib/tests/test_local_working_copy.rs @@ -50,11 +50,13 @@ use jj_lib::working_copy::CheckoutStats; use jj_lib::working_copy::SnapshotOptions; use jj_lib::working_copy::UntrackedReason; use jj_lib::working_copy::WorkingCopy as _; -use jj_lib::workspace::default_working_copy_factories; use jj_lib::workspace::LockedWorkspace; use jj_lib::workspace::Workspace; +use jj_lib::workspace::default_working_copy_factories; use pollster::FutureExt as _; use test_case::test_case; +use testutils::TestRepoBackend; +use testutils::TestWorkspace; use testutils::commit_with_tree; use testutils::create_tree; use testutils::create_tree_with; @@ -62,8 +64,6 @@ use testutils::repo_path; use testutils::repo_path_buf; use testutils::repo_path_component; use testutils::write_random_commit; -use testutils::TestRepoBackend; -use testutils::TestWorkspace; fn check_icase_fs(dir: &Path) -> bool { let test_file = tempfile::Builder::new() @@ -516,21 +516,31 @@ fn test_acl() { &CheckoutOptions::empty_for_test(), ) .unwrap(); - assert!(!secret_modified_path - .to_fs_path_unchecked(&workspace_root) - .is_file()); - assert!(!secret_added_path - .to_fs_path_unchecked(&workspace_root) - .is_file()); - assert!(!secret_deleted_path - .to_fs_path_unchecked(&workspace_root) - .is_file()); - assert!(became_secret_path - .to_fs_path_unchecked(&workspace_root) - .is_file()); - assert!(!became_public_path - .to_fs_path_unchecked(&workspace_root) - .is_file()); + assert!( + !secret_modified_path + .to_fs_path_unchecked(&workspace_root) + .is_file() + ); + assert!( + !secret_added_path + .to_fs_path_unchecked(&workspace_root) + .is_file() + ); + assert!( + !secret_deleted_path + .to_fs_path_unchecked(&workspace_root) + .is_file() + ); + assert!( + became_secret_path + .to_fs_path_unchecked(&workspace_root) + .is_file() + ); + assert!( + !became_public_path + .to_fs_path_unchecked(&workspace_root) + .is_file() + ); ws.check_out( repo.op_id().clone(), None, @@ -538,21 +548,31 @@ fn test_acl() { &CheckoutOptions::empty_for_test(), ) .unwrap(); - assert!(!secret_modified_path - .to_fs_path_unchecked(&workspace_root) - .is_file()); - assert!(!secret_added_path - .to_fs_path_unchecked(&workspace_root) - .is_file()); - assert!(!secret_deleted_path - .to_fs_path_unchecked(&workspace_root) - .is_file()); - assert!(!became_secret_path - .to_fs_path_unchecked(&workspace_root) - .is_file()); - assert!(became_public_path - .to_fs_path_unchecked(&workspace_root) - .is_file()); + assert!( + !secret_modified_path + .to_fs_path_unchecked(&workspace_root) + .is_file() + ); + assert!( + !secret_added_path + .to_fs_path_unchecked(&workspace_root) + .is_file() + ); + assert!( + !secret_deleted_path + .to_fs_path_unchecked(&workspace_root) + .is_file() + ); + assert!( + !became_secret_path + .to_fs_path_unchecked(&workspace_root) + .is_file() + ); + assert!( + became_public_path + .to_fs_path_unchecked(&workspace_root) + .is_file() + ); } #[test] @@ -1217,14 +1237,15 @@ fn test_gitignores_checkout_never_overwrites_ignored() { // "contents". The exiting contents ("garbage") shouldn't be replaced in the // working copy. let ws = &mut test_workspace.workspace; - assert!(ws - .check_out( + assert!( + ws.check_out( repo.op_id().clone(), None, &commit, &CheckoutOptions::empty_for_test() ) - .is_ok()); + .is_ok() + ); // Check that the old contents are in the working copy let path = workspace_root.join("modified"); diff --git a/lib/tests/test_local_working_copy_concurrent.rs b/lib/tests/test_local_working_copy_concurrent.rs index f09c854cc..f51dc32e8 100644 --- a/lib/tests/test_local_working_copy_concurrent.rs +++ b/lib/tests/test_local_working_copy_concurrent.rs @@ -20,14 +20,14 @@ use jj_lib::repo::Repo as _; use jj_lib::working_copy::CheckoutError; use jj_lib::working_copy::CheckoutOptions; use jj_lib::working_copy::SnapshotOptions; -use jj_lib::workspace::default_working_copy_factories; use jj_lib::workspace::Workspace; +use jj_lib::workspace::default_working_copy_factories; +use testutils::TestWorkspace; use testutils::commit_with_tree; use testutils::create_tree; use testutils::repo_path; use testutils::repo_path_buf; use testutils::write_working_copy_file; -use testutils::TestWorkspace; #[test] fn test_concurrent_checkout() { diff --git a/lib/tests/test_local_working_copy_sparse.rs b/lib/tests/test_local_working_copy_sparse.rs index 24b0a89e0..c1c4c29c7 100644 --- a/lib/tests/test_local_working_copy_sparse.rs +++ b/lib/tests/test_local_working_copy_sparse.rs @@ -23,10 +23,10 @@ use jj_lib::working_copy::CheckoutOptions; use jj_lib::working_copy::CheckoutStats; use jj_lib::working_copy::WorkingCopy as _; use pollster::FutureExt as _; +use testutils::TestWorkspace; use testutils::commit_with_tree; use testutils::create_tree; use testutils::repo_path; -use testutils::TestWorkspace; fn to_owned_path_vec(paths: &[&RepoPath]) -> Vec { paths.iter().map(|&path| path.to_owned()).collect() @@ -92,24 +92,36 @@ fn test_sparse_checkout() { locked_ws.locked_wc().sparse_patterns().unwrap(), sparse_patterns ); - assert!(!root_file1_path - .to_fs_path_unchecked(&working_copy_path) - .exists()); - assert!(!root_file2_path - .to_fs_path_unchecked(&working_copy_path) - .exists()); - assert!(dir1_file1_path - .to_fs_path_unchecked(&working_copy_path) - .exists()); - assert!(dir1_file2_path - .to_fs_path_unchecked(&working_copy_path) - .exists()); - assert!(dir1_subdir1_file1_path - .to_fs_path_unchecked(&working_copy_path) - .exists()); - assert!(!dir2_file1_path - .to_fs_path_unchecked(&working_copy_path) - .exists()); + assert!( + !root_file1_path + .to_fs_path_unchecked(&working_copy_path) + .exists() + ); + assert!( + !root_file2_path + .to_fs_path_unchecked(&working_copy_path) + .exists() + ); + assert!( + dir1_file1_path + .to_fs_path_unchecked(&working_copy_path) + .exists() + ); + assert!( + dir1_file2_path + .to_fs_path_unchecked(&working_copy_path) + .exists() + ); + assert!( + dir1_subdir1_file1_path + .to_fs_path_unchecked(&working_copy_path) + .exists() + ); + assert!( + !dir2_file1_path + .to_fs_path_unchecked(&working_copy_path) + .exists() + ); // Write the new state to disk locked_ws.finish(repo.op_id().clone()).unwrap(); @@ -150,24 +162,36 @@ fn test_sparse_checkout() { } ); assert_eq!(locked_wc.sparse_patterns().unwrap(), sparse_patterns); - assert!(root_file1_path - .to_fs_path_unchecked(&working_copy_path) - .exists()); - assert!(!root_file2_path - .to_fs_path_unchecked(&working_copy_path) - .exists()); - assert!(!dir1_file1_path - .to_fs_path_unchecked(&working_copy_path) - .exists()); - assert!(!dir1_file2_path - .to_fs_path_unchecked(&working_copy_path) - .exists()); - assert!(dir1_subdir1_file1_path - .to_fs_path_unchecked(&working_copy_path) - .exists()); - assert!(dir2_file1_path - .to_fs_path_unchecked(&working_copy_path) - .exists()); + assert!( + root_file1_path + .to_fs_path_unchecked(&working_copy_path) + .exists() + ); + assert!( + !root_file2_path + .to_fs_path_unchecked(&working_copy_path) + .exists() + ); + assert!( + !dir1_file1_path + .to_fs_path_unchecked(&working_copy_path) + .exists() + ); + assert!( + !dir1_file2_path + .to_fs_path_unchecked(&working_copy_path) + .exists() + ); + assert!( + dir1_subdir1_file1_path + .to_fs_path_unchecked(&working_copy_path) + .exists() + ); + assert!( + dir2_file1_path + .to_fs_path_unchecked(&working_copy_path) + .exists() + ); let wc = locked_wc.finish(repo.op_id().clone()).unwrap(); let wc: &LocalWorkingCopy = wc.as_any().downcast_ref().unwrap(); assert_eq!( diff --git a/lib/tests/test_merge_trees.rs b/lib/tests/test_merge_trees.rs index 0509a1f52..8abcb9975 100644 --- a/lib/tests/test_merge_trees.rs +++ b/lib/tests/test_merge_trees.rs @@ -17,9 +17,9 @@ use jj_lib::backend::TreeValue; use jj_lib::merge::Merge; use jj_lib::repo::Repo as _; use jj_lib::rewrite::rebase_commit; +use testutils::TestRepo; use testutils::create_tree; use testutils::repo_path; -use testutils::TestRepo; #[test] fn test_simplify_conflict_after_resolving_parent() { diff --git a/lib/tests/test_merged_tree.rs b/lib/tests/test_merged_tree.rs index 1dfc24f5a..4cfedb7b0 100644 --- a/lib/tests/test_merged_tree.rs +++ b/lib/tests/test_merged_tree.rs @@ -42,13 +42,13 @@ use jj_lib::repo_path::RepoPathBuf; use jj_lib::tree_builder::TreeBuilder; use pollster::FutureExt as _; use pretty_assertions::assert_eq; +use testutils::TestRepo; use testutils::create_single_tree; use testutils::create_tree; use testutils::repo_path; use testutils::repo_path_buf; use testutils::repo_path_component; use testutils::write_file; -use testutils::TestRepo; fn file_value(file_id: &FileId) -> TreeValue { TreeValue::File { diff --git a/lib/tests/test_mut_repo.rs b/lib/tests/test_mut_repo.rs index f98b37061..08fbaf87a 100644 --- a/lib/tests/test_mut_repo.rs +++ b/lib/tests/test_mut_repo.rs @@ -25,13 +25,13 @@ use jj_lib::repo::Repo as _; use jj_lib::rewrite::RebaseOptions; use maplit::hashset; use pollster::FutureExt as _; +use testutils::CommitGraphBuilder; +use testutils::TestRepo; use testutils::assert_rebased_onto; use testutils::create_random_commit; use testutils::create_random_tree; use testutils::rebase_descendants_with_options_return_map; use testutils::write_random_commit; -use testutils::CommitGraphBuilder; -use testutils::TestRepo; fn remote_symbol<'a, N, M>(name: &'a N, remote: &'a M) -> RemoteRefSymbol<'a> where diff --git a/lib/tests/test_operations.rs b/lib/tests/test_operations.rs index d34989e8f..d92a889e5 100644 --- a/lib/tests/test_operations.rs +++ b/lib/tests/test_operations.rs @@ -33,10 +33,10 @@ use jj_lib::repo::ReadonlyRepo; use jj_lib::repo::Repo; use jj_lib::settings::UserSettings; use test_case::test_case; -use testutils::create_random_commit; -use testutils::write_random_commit; use testutils::CommitGraphBuilder; use testutils::TestRepo; +use testutils::create_random_commit; +use testutils::write_random_commit; fn get_predecessors(repo: &ReadonlyRepo, id: &CommitId) -> Vec { let entries: Vec<_> = walk_predecessors(repo, slice::from_ref(id)) diff --git a/lib/tests/test_revset.rs b/lib/tests/test_revset.rs index 3dbb622a8..9e8fa3ed7 100644 --- a/lib/tests/test_revset.rs +++ b/lib/tests/test_revset.rs @@ -27,8 +27,8 @@ use jj_lib::backend::Timestamp; use jj_lib::commit::Commit; use jj_lib::fileset::FilesetExpression; use jj_lib::git; -use jj_lib::graph::reverse_graph; use jj_lib::graph::GraphEdge; +use jj_lib::graph::reverse_graph; use jj_lib::id_prefix::IdPrefixContext; use jj_lib::object_id::ObjectId as _; use jj_lib::op_store::RefTarget; @@ -42,7 +42,6 @@ use jj_lib::ref_name::WorkspaceNameBuf; use jj_lib::repo::Repo; use jj_lib::repo_path::RepoPath; use jj_lib::repo_path::RepoPathUiConverter; -use jj_lib::revset::parse; use jj_lib::revset::Revset; use jj_lib::revset::RevsetAliasesMap; use jj_lib::revset::RevsetDiagnostics; @@ -54,21 +53,22 @@ use jj_lib::revset::RevsetResolutionError; use jj_lib::revset::RevsetWorkspaceContext; use jj_lib::revset::SymbolResolver; use jj_lib::revset::SymbolResolverExtension; +use jj_lib::revset::parse; use jj_lib::signing::SignBehavior; use jj_lib::signing::Signer; use jj_lib::test_signing_backend::TestSigningBackend; use jj_lib::workspace::Workspace; use pollster::FutureExt as _; use test_case::test_case; +use testutils::CommitGraphBuilder; +use testutils::TestRepo; +use testutils::TestRepoBackend; +use testutils::TestWorkspace; use testutils::create_random_commit; use testutils::create_tree; use testutils::create_tree_with; use testutils::repo_path; use testutils::write_random_commit; -use testutils::CommitGraphBuilder; -use testutils::TestRepo; -use testutils::TestRepoBackend; -use testutils::TestWorkspace; fn remote_symbol<'a, N, M>(name: &'a N, remote: &'a M) -> RemoteRefSymbol<'a> where diff --git a/lib/tests/test_rewrite.rs b/lib/tests/test_rewrite.rs index f16740a25..8806cbafc 100644 --- a/lib/tests/test_rewrite.rs +++ b/lib/tests/test_rewrite.rs @@ -28,19 +28,21 @@ use jj_lib::ref_name::RemoteRefSymbol; use jj_lib::ref_name::WorkspaceName; use jj_lib::ref_name::WorkspaceNameBuf; use jj_lib::repo::Repo as _; -use jj_lib::rewrite::find_duplicate_divergent_commits; -use jj_lib::rewrite::rebase_commit_with_options; -use jj_lib::rewrite::restore_tree; use jj_lib::rewrite::CommitRewriter; use jj_lib::rewrite::CommitWithSelection; use jj_lib::rewrite::EmptyBehavior; use jj_lib::rewrite::MoveCommitsTarget; use jj_lib::rewrite::RebaseOptions; use jj_lib::rewrite::RewriteRefsOptions; +use jj_lib::rewrite::find_duplicate_divergent_commits; +use jj_lib::rewrite::rebase_commit_with_options; +use jj_lib::rewrite::restore_tree; use maplit::hashmap; use maplit::hashset; use pollster::FutureExt as _; use test_case::test_case; +use testutils::CommitGraphBuilder; +use testutils::TestRepo; use testutils::assert_abandoned_with_parent; use testutils::assert_rebased_onto; use testutils::create_random_commit; @@ -49,8 +51,6 @@ use testutils::create_tree_with; use testutils::rebase_descendants_with_options_return_map; use testutils::repo_path; use testutils::write_random_commit; -use testutils::CommitGraphBuilder; -use testutils::TestRepo; fn remote_symbol<'a, N, M>(name: &'a N, remote: &'a M) -> RemoteRefSymbol<'a> where diff --git a/lib/tests/test_rewrite_duplicate.rs b/lib/tests/test_rewrite_duplicate.rs index 83abdc000..519cf5cce 100644 --- a/lib/tests/test_rewrite_duplicate.rs +++ b/lib/tests/test_rewrite_duplicate.rs @@ -19,9 +19,9 @@ use jj_lib::backend::CommitId; use jj_lib::repo::Repo as _; use jj_lib::rewrite::duplicate_commits; use jj_lib::transaction::Transaction; +use testutils::TestRepo; use testutils::create_tree; use testutils::repo_path; -use testutils::TestRepo; #[test] fn test_duplicate_linear_contents() { diff --git a/lib/tests/test_signing.rs b/lib/tests/test_signing.rs index 00afec0f9..c01b352db 100644 --- a/lib/tests/test_signing.rs +++ b/lib/tests/test_signing.rs @@ -11,10 +11,10 @@ use jj_lib::signing::Signer; use jj_lib::signing::Verification; use jj_lib::test_signing_backend::TestSigningBackend; use test_case::test_case; -use testutils::create_random_commit; -use testutils::write_random_commit; use testutils::TestRepoBackend; use testutils::TestWorkspace; +use testutils::create_random_commit; +use testutils::write_random_commit; fn user_settings(behavior: SignBehavior) -> UserSettings { let mut config = testutils::base_user_config(); diff --git a/lib/tests/test_view.rs b/lib/tests/test_view.rs index 7c0233fac..bbac75045 100644 --- a/lib/tests/test_view.rs +++ b/lib/tests/test_view.rs @@ -26,11 +26,11 @@ use jj_lib::repo::Repo as _; use maplit::btreemap; use maplit::hashset; use test_case::test_case; +use testutils::CommitGraphBuilder; +use testutils::TestRepo; use testutils::commit_transactions; use testutils::create_random_commit; use testutils::write_random_commit; -use testutils::CommitGraphBuilder; -use testutils::TestRepo; fn remote_symbol<'a, N, M>(name: &'a N, remote: &'a M) -> RemoteRefSymbol<'a> where diff --git a/lib/tests/test_workspace.rs b/lib/tests/test_workspace.rs index 56eb629f4..628418b05 100644 --- a/lib/tests/test_workspace.rs +++ b/lib/tests/test_workspace.rs @@ -17,10 +17,10 @@ use std::thread; use assert_matches::assert_matches; use jj_lib::ref_name::WorkspaceNameBuf; use jj_lib::repo::Repo as _; -use jj_lib::workspace::default_working_copy_factories; -use jj_lib::workspace::default_working_copy_factory; use jj_lib::workspace::Workspace; use jj_lib::workspace::WorkspaceLoadError; +use jj_lib::workspace::default_working_copy_factories; +use jj_lib::workspace::default_working_copy_factory; use testutils::TestEnvironment; use testutils::TestWorkspace; diff --git a/lib/testutils/src/lib.rs b/lib/testutils/src/lib.rs index aa747f5d3..98d77ff0e 100644 --- a/lib/testutils/src/lib.rs +++ b/lib/testutils/src/lib.rs @@ -673,8 +673,7 @@ fn assert_in_rebased_map( expected_old_commit.id().hex() ) }); - let new_commit = repo.store().get_commit(new_commit_id).unwrap().clone(); - new_commit + repo.store().get_commit(new_commit_id).unwrap().clone() } pub fn assert_rebased_onto( diff --git a/lib/testutils/src/test_backend.rs b/lib/testutils/src/test_backend.rs index 3fc8a9b76..d505491b0 100644 --- a/lib/testutils/src/test_backend.rs +++ b/lib/testutils/src/test_backend.rs @@ -29,7 +29,6 @@ use std::time::SystemTime; use async_trait::async_trait; use futures::stream; use futures::stream::BoxStream; -use jj_lib::backend::make_root_commit; use jj_lib::backend::Backend; use jj_lib::backend::BackendError; use jj_lib::backend::BackendResult; @@ -47,6 +46,7 @@ use jj_lib::backend::SigningFn; use jj_lib::backend::SymlinkId; use jj_lib::backend::Tree; use jj_lib::backend::TreeId; +use jj_lib::backend::make_root_commit; use jj_lib::dag_walk::topo_order_reverse; use jj_lib::index::Index; use jj_lib::object_id::ObjectId as _; @@ -488,10 +488,12 @@ mod tests { let copy3_id = backend.write_copy(©3).block_on().unwrap(); // Error when looking up by non-existent id - assert!(backend - .get_related_copies(&CopyId::from_hex("abcd")) - .block_on() - .is_err()); + assert!( + backend + .get_related_copies(&CopyId::from_hex("abcd")) + .block_on() + .is_err() + ); // Looking up by any id returns the related copies in the same order (children // before parents)