From a7f4f4cf5b27205d0f4c8d7ae09d3acc78a5d422 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 14 Mar 2021 10:46:35 -0700 Subject: [PATCH] rustfmt: configure to merge imports by module Perhaps we should even set the config to "Item" to reduce merge conflicts. --- lib/src/git_store.rs | 3 +-- lib/src/local_store.rs | 3 +-- lib/src/lock.rs | 3 +-- lib/src/matchers.rs | 15 +++++---------- lib/src/op_heads_store.rs | 3 +-- lib/src/repo.rs | 4 +--- lib/src/simple_op_store.rs | 3 +-- lib/src/store.rs | 3 +-- lib/src/transaction.rs | 6 ++---- lib/src/working_copy.rs | 3 +-- lib/tests/test_commit_concurrent.rs | 3 +-- lib/tests/test_evolution.rs | 3 +-- lib/tests/test_git.rs | 3 +-- lib/tests/test_merge_trees.rs | 3 +-- rustfmt.toml | 1 + src/commands.rs | 13 ++++--------- src/template_parser.rs | 3 +-- src/ui.rs | 3 +-- 18 files changed, 26 insertions(+), 52 deletions(-) diff --git a/lib/src/git_store.rs b/lib/src/git_store.rs index c166bab22..02d4c53cb 100644 --- a/lib/src/git_store.rs +++ b/lib/src/git_store.rs @@ -13,8 +13,7 @@ // limitations under the License. use std::fmt::{Debug, Error, Formatter}; -use std::io::Cursor; -use std::io::Read; +use std::io::{Cursor, Read}; use std::ops::Deref; use std::path::Path; use std::sync::Mutex; diff --git a/lib/src/local_store.rs b/lib/src/local_store.rs index 7ceb79578..832d4d051 100644 --- a/lib/src/local_store.rs +++ b/lib/src/local_store.rs @@ -15,8 +15,7 @@ use std::fmt::Debug; use std::fs; use std::fs::File; -use std::io::Write; -use std::io::{ErrorKind, Read}; +use std::io::{ErrorKind, Read, Write}; use std::path::PathBuf; use blake2::{Blake2b, Digest}; diff --git a/lib/src/lock.rs b/lib/src/lock.rs index 08dc938ec..193e5725f 100644 --- a/lib/src/lock.rs +++ b/lib/src/lock.rs @@ -62,8 +62,7 @@ impl Drop for FileLock { #[cfg(test)] mod tests { - use std::env; - use std::thread; + use std::{env, thread}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; diff --git a/lib/src/matchers.rs b/lib/src/matchers.rs index 2cab180fb..b14dd06b8 100644 --- a/lib/src/matchers.rs +++ b/lib/src/matchers.rs @@ -14,13 +14,9 @@ #![allow(dead_code)] -use std::collections::HashMap; -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; -use crate::repo_path::DirRepoPath; -use crate::repo_path::DirRepoPathComponent; -use crate::repo_path::FileRepoPath; -use crate::repo_path::FileRepoPathComponent; +use crate::repo_path::{DirRepoPath, DirRepoPathComponent, FileRepoPath, FileRepoPathComponent}; #[derive(PartialEq, Eq, Debug)] pub struct Visit<'a> { @@ -156,10 +152,9 @@ mod tests { use std::collections::HashSet; use super::*; - use crate::repo_path::DirRepoPath; - use crate::repo_path::DirRepoPathComponent; - use crate::repo_path::FileRepoPath; - use crate::repo_path::FileRepoPathComponent; + use crate::repo_path::{ + DirRepoPath, DirRepoPathComponent, FileRepoPath, FileRepoPathComponent, + }; #[test] fn dirs_empty() { diff --git a/lib/src/op_heads_store.rs b/lib/src/op_heads_store.rs index 22fccf3d0..9934db36a 100644 --- a/lib/src/op_heads_store.rs +++ b/lib/src/op_heads_store.rs @@ -18,14 +18,13 @@ use std::sync::Arc; use thiserror::Error; -use crate::dag_walk; use crate::lock::FileLock; -use crate::op_store; use crate::op_store::{OpStore, OperationId, OperationMetadata}; use crate::operation::Operation; use crate::repo::RepoLoader; use crate::store::{CommitId, Timestamp}; use crate::transaction::UnpublishedOperation; +use crate::{dag_walk, op_store}; /// Manages the very set of current heads of the operation log. The store is /// simply a directory where each operation id is a file with that name (and no diff --git a/lib/src/repo.rs b/lib/src/repo.rs index 6bbc62379..7754eeaeb 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -23,7 +23,6 @@ use thiserror::Error; use crate::commit::Commit; use crate::commit_builder::{new_change_id, signature, CommitBuilder}; -use crate::conflicts; use crate::dag_walk::topo_order_reverse; use crate::evolution::{EvolutionRef, MutableEvolution, ReadonlyEvolution}; use crate::git_store::GitStore; @@ -31,17 +30,16 @@ use crate::index::{IndexRef, MutableIndex, ReadonlyIndex}; use crate::index_store::IndexStore; use crate::local_store::LocalStore; use crate::op_heads_store::OpHeadsStore; -use crate::op_store; use crate::op_store::{OpStore, OperationId}; use crate::operation::Operation; use crate::settings::{RepoSettings, UserSettings}; use crate::simple_op_store::SimpleOpStore; -use crate::store; use crate::store::{CommitId, Store, StoreError}; use crate::store_wrapper::StoreWrapper; use crate::transaction::Transaction; use crate::view::{merge_views, MutableView, ReadonlyView, ViewRef}; use crate::working_copy::WorkingCopy; +use crate::{conflicts, op_store, store}; #[derive(Debug, Error, PartialEq, Eq)] pub enum RepoError { diff --git a/lib/src/simple_op_store.rs b/lib/src/simple_op_store.rs index 93e9b6e0b..693492151 100644 --- a/lib/src/simple_op_store.rs +++ b/lib/src/simple_op_store.rs @@ -15,8 +15,7 @@ use std::fmt::Debug; use std::fs; use std::fs::File; -use std::io::ErrorKind; -use std::io::Write; +use std::io::{ErrorKind, Write}; use std::path::PathBuf; use blake2::{Blake2b, Digest}; diff --git a/lib/src/store.rs b/lib/src/store.rs index 115cae039..ac0931d6d 100644 --- a/lib/src/store.rs +++ b/lib/src/store.rs @@ -21,8 +21,7 @@ use std::vec::Vec; use thiserror::Error; -use crate::repo_path::DirRepoPath; -use crate::repo_path::FileRepoPath; +use crate::repo_path::{DirRepoPath, FileRepoPath}; #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Hash)] pub struct CommitId(pub Vec); diff --git a/lib/src/transaction.rs b/lib/src/transaction.rs index 6bb0a36c3..740132328 100644 --- a/lib/src/transaction.rs +++ b/lib/src/transaction.rs @@ -18,16 +18,14 @@ use crate::commit::Commit; use crate::evolution::MutableEvolution; use crate::index::MutableIndex; use crate::op_heads_store::OpHeadsStore; -use crate::op_store; -use crate::op_store::OperationId; -use crate::op_store::OperationMetadata; +use crate::op_store::{OperationId, OperationMetadata}; use crate::operation::Operation; use crate::repo::{MutableRepo, ReadonlyRepo, RepoRef}; use crate::settings::UserSettings; -use crate::store; use crate::store::{CommitId, Timestamp}; use crate::store_wrapper::StoreWrapper; use crate::view::MutableView; +use crate::{op_store, store}; pub struct Transaction<'r> { repo: Option>>, diff --git a/lib/src/working_copy.rs b/lib/src/working_copy.rs index 4e77e6cb5..94eab7e3b 100644 --- a/lib/src/working_copy.rs +++ b/lib/src/working_copy.rs @@ -23,8 +23,7 @@ use std::os::unix::fs::symlink; use std::os::unix::fs::PermissionsExt; #[cfg(windows)] use std::os::windows::fs::symlink_file; -use std::path::Path; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::sync::Arc; use std::time::UNIX_EPOCH; diff --git a/lib/tests/test_commit_concurrent.rs b/lib/tests/test_commit_concurrent.rs index 68bec48b9..c30404c01 100644 --- a/lib/tests/test_commit_concurrent.rs +++ b/lib/tests/test_commit_concurrent.rs @@ -15,9 +15,8 @@ use std::sync::Arc; use std::thread; -use jujube_lib::dag_walk; use jujube_lib::repo::ReadonlyRepo; -use jujube_lib::testutils; +use jujube_lib::{dag_walk, testutils}; use test_case::test_case; fn count_non_merge_operations(repo: &ReadonlyRepo) -> u32 { diff --git a/lib/tests/test_evolution.rs b/lib/tests/test_evolution.rs index 161804e93..a12aec0fb 100644 --- a/lib/tests/test_evolution.rs +++ b/lib/tests/test_evolution.rs @@ -14,8 +14,7 @@ use jujube_lib::commit::Commit; use jujube_lib::commit_builder::CommitBuilder; -use jujube_lib::evolution::evolve; -use jujube_lib::evolution::EvolveListener; +use jujube_lib::evolution::{evolve, EvolveListener}; use jujube_lib::repo::ReadonlyRepo; use jujube_lib::repo_path::FileRepoPath; use jujube_lib::settings::UserSettings; diff --git a/lib/tests/test_git.rs b/lib/tests/test_git.rs index f2a3d3aef..4ed137f20 100644 --- a/lib/tests/test_git.rs +++ b/lib/tests/test_git.rs @@ -18,12 +18,11 @@ use std::sync::Arc; use git2::Oid; use jujube_lib::commit::Commit; -use jujube_lib::git; use jujube_lib::git::{GitFetchError, GitPushError}; use jujube_lib::repo::ReadonlyRepo; use jujube_lib::settings::UserSettings; use jujube_lib::store::CommitId; -use jujube_lib::testutils; +use jujube_lib::{git, testutils}; use maplit::hashset; use tempfile::TempDir; diff --git a/lib/tests/test_merge_trees.rs b/lib/tests/test_merge_trees.rs index d7154cd86..db4916f0c 100644 --- a/lib/tests/test_merge_trees.rs +++ b/lib/tests/test_merge_trees.rs @@ -14,9 +14,8 @@ use jujube_lib::repo_path::{DirRepoPath, FileRepoPath, RepoPath}; use jujube_lib::store::{ConflictPart, TreeValue}; -use jujube_lib::testutils; use jujube_lib::tree::Tree; -use jujube_lib::trees; +use jujube_lib::{testutils, trees}; use test_case::test_case; #[test_case(false ; "local store")] diff --git a/rustfmt.toml b/rustfmt.toml index b8d5849ba..d0a79cefb 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -2,3 +2,4 @@ max_width = 100 wrap_comments = true error_on_line_overflow = true group_imports = "StdExternalCrate" +imports_granularity = "Module" diff --git a/src/commands.rs b/src/commands.rs index 90bc1477e..e8d49f6bd 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -19,25 +19,20 @@ extern crate config; use std::collections::{HashSet, VecDeque}; use std::ffi::OsString; use std::fmt::Debug; -use std::fs; use std::fs::OpenOptions; -use std::io; use std::io::{Read, Write}; use std::process::Command; use std::sync::Arc; use std::time::Instant; +use std::{fs, io}; use clap::{crate_version, App, Arg, ArgMatches, SubCommand}; use criterion::Criterion; use jujube_lib::commit::Commit; use jujube_lib::commit_builder::CommitBuilder; -use jujube_lib::conflicts; use jujube_lib::dag_walk::{topo_order_reverse, walk_ancestors}; -use jujube_lib::evolution::evolve; -use jujube_lib::evolution::EvolveListener; -use jujube_lib::files; +use jujube_lib::evolution::{evolve, EvolveListener}; use jujube_lib::files::DiffLine; -use jujube_lib::git; use jujube_lib::git::GitFetchError; use jujube_lib::index::{HexPrefix, PrefixResolution}; use jujube_lib::op_store::{OpStore, OpStoreError, OperationId}; @@ -46,14 +41,14 @@ use jujube_lib::repo::{ReadonlyRepo, RepoLoadError, RepoLoader}; use jujube_lib::repo_path::RepoPath; use jujube_lib::rewrite::{back_out_commit, merge_commit_trees, rebase_commit}; use jujube_lib::settings::UserSettings; -use jujube_lib::store::{CommitId, Timestamp}; -use jujube_lib::store::{StoreError, TreeValue}; +use jujube_lib::store::{CommitId, StoreError, Timestamp, TreeValue}; use jujube_lib::store_wrapper::StoreWrapper; use jujube_lib::transaction::Transaction; use jujube_lib::tree::Tree; use jujube_lib::trees::TreeValueDiff; use jujube_lib::view::merge_views; use jujube_lib::working_copy::{CheckoutStats, WorkingCopy}; +use jujube_lib::{conflicts, files, git}; use pest::Parser; use self::chrono::{FixedOffset, TimeZone, Utc}; diff --git a/src/template_parser.rs b/src/template_parser.rs index dcbc9dbce..6e646da7e 100644 --- a/src/template_parser.rs +++ b/src/template_parser.rs @@ -17,8 +17,7 @@ extern crate pest; use jujube_lib::commit::Commit; use jujube_lib::repo::RepoRef; use jujube_lib::store::{CommitId, Signature}; -use pest::iterators::Pair; -use pest::iterators::Pairs; +use pest::iterators::{Pair, Pairs}; use pest::Parser; use crate::styler::PlainTextStyler; diff --git a/src/ui.rs b/src/ui.rs index 2f63463d8..e75036610 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -12,11 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::fmt; -use std::io; use std::io::Write; use std::path::{Path, PathBuf}; use std::sync::{Mutex, MutexGuard}; +use std::{fmt, io}; use jujube_lib::commit::Commit; use jujube_lib::repo::RepoRef;