forked from mirrors/jj
cleanup: let new Clippy move variables into format strings
I ran an upgraded Clippy on the codebase. All the changes seem to be about using variables directly in format strings instead of passing them as separate arguments.
This commit is contained in:
parent
c8a04d6f69
commit
7f9a0a2820
25 changed files with 137 additions and 157 deletions
|
@ -5,7 +5,7 @@ use jujutsu_lib::diff;
|
|||
fn unchanged_lines(count: usize) -> (String, String) {
|
||||
let mut lines = vec![];
|
||||
for i in 0..count {
|
||||
lines.push(format!("left line {}\n", i));
|
||||
lines.push(format!("left line {i}\n"));
|
||||
}
|
||||
(lines.join(""), lines.join(""))
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ fn modified_lines(count: usize) -> (String, String) {
|
|||
let mut left_lines = vec![];
|
||||
let mut right_lines = vec![];
|
||||
for i in 0..count {
|
||||
left_lines.push(format!("left line {}\n", i));
|
||||
right_lines.push(format!("right line {}\n", i));
|
||||
left_lines.push(format!("left line {i}\n"));
|
||||
right_lines.push(format!("right line {i}\n"));
|
||||
}
|
||||
(left_lines.join(""), right_lines.join(""))
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ fn modified_lines(count: usize) -> (String, String) {
|
|||
fn reversed_lines(count: usize) -> (String, String) {
|
||||
let mut left_lines = vec![];
|
||||
for i in 0..count {
|
||||
left_lines.push(format!("left line {}\n", i));
|
||||
left_lines.push(format!("left line {i}\n"));
|
||||
}
|
||||
let mut right_lines = left_lines.clone();
|
||||
right_lines.reverse();
|
||||
|
|
|
@ -36,7 +36,7 @@ fn main() {
|
|||
.run_from_script();
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
for file in input {
|
||||
println!("cargo:rerun-if-changed={}", file);
|
||||
println!("cargo:rerun-if-changed={file}");
|
||||
}
|
||||
|
||||
if let Some(true) = version_check::supports_feature("map_first_last") {
|
||||
|
|
|
@ -257,7 +257,7 @@ pub fn export_refs(
|
|||
}
|
||||
}
|
||||
for (branch_name, old_oid) in branches_to_delete {
|
||||
let git_ref_name = format!("refs/heads/{}", branch_name);
|
||||
let git_ref_name = format!("refs/heads/{branch_name}");
|
||||
let success = if let Ok(mut git_ref) = git_repo.find_reference(&git_ref_name) {
|
||||
if git_ref.target() == Some(old_oid) {
|
||||
// The branch has not been updated by git, so go ahead and delete it
|
||||
|
@ -277,7 +277,7 @@ pub fn export_refs(
|
|||
}
|
||||
}
|
||||
for (branch_name, (old_oid, new_oid)) in branches_to_update {
|
||||
let git_ref_name = format!("refs/heads/{}", branch_name);
|
||||
let git_ref_name = format!("refs/heads/{branch_name}");
|
||||
let success = match old_oid {
|
||||
None => {
|
||||
if let Ok(git_ref) = git_repo.find_reference(&git_ref_name) {
|
||||
|
@ -416,7 +416,7 @@ pub fn push_commit(
|
|||
git_repo,
|
||||
remote_name,
|
||||
&[GitRefUpdate {
|
||||
qualified_name: format!("refs/heads/{}", remote_branch),
|
||||
qualified_name: format!("refs/heads/{remote_branch}"),
|
||||
force,
|
||||
new_target: Some(target.id().clone()),
|
||||
}],
|
||||
|
|
|
@ -273,13 +273,13 @@ impl Backend for GitBackend {
|
|||
let id = SymlinkId::from_bytes(entry.id().as_bytes());
|
||||
(name, TreeValue::Symlink(id))
|
||||
}
|
||||
mode => panic!("unexpected file mode {:?}", mode),
|
||||
mode => panic!("unexpected file mode {mode:?}"),
|
||||
},
|
||||
git2::ObjectType::Commit => {
|
||||
let id = CommitId::from_bytes(entry.id().as_bytes());
|
||||
(name, TreeValue::GitSubmodule(id))
|
||||
}
|
||||
kind => panic!("unexpected object type {:?}", kind),
|
||||
kind => panic!("unexpected object type {kind:?}"),
|
||||
};
|
||||
tree.set(RepoPathComponent::from(name), value);
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ fn tree_value_from_json(json: &serde_json::Value) -> TreeValue {
|
|||
} else if let Some(json_id) = json.get("conflict_id") {
|
||||
TreeValue::Conflict(ConflictId::new(bytes_vec_from_json(json_id)))
|
||||
} else {
|
||||
panic!("unexpected json value in conflict: {:#?}", json);
|
||||
panic!("unexpected json value in conflict: {json:#?}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -708,7 +708,7 @@ mod tests {
|
|||
panic!("expectedly successfully wrote two commits with the same git commit object")
|
||||
}
|
||||
Err(BackendError::Other(message)) if message.contains(&expected_error_message) => {}
|
||||
Err(err) => panic!("unexpected error: {:?}", err),
|
||||
Err(err) => panic!("unexpected error: {err:?}"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -568,7 +568,7 @@ impl MutableIndex {
|
|||
ReadonlyIndex::load_from(&mut cursor, dir, index_file_id_hex, hash_length).map_err(|err| {
|
||||
match err {
|
||||
IndexLoadError::IndexCorrupt(err) => {
|
||||
panic!("Just-created index file is corrupt: {}", err)
|
||||
panic!("Just-created index file is corrupt: {err}")
|
||||
}
|
||||
IndexLoadError::IoError(err) => err,
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ impl Dirs {
|
|||
fn add_file(&mut self, file: &RepoPath) {
|
||||
let (dir, basename) = file
|
||||
.split()
|
||||
.unwrap_or_else(|| panic!("got empty filename: {:?}", file));
|
||||
.unwrap_or_else(|| panic!("got empty filename: {file:?}"));
|
||||
self.add_dir(&dir);
|
||||
self.files.entry(dir).or_default().insert(basename.clone());
|
||||
}
|
||||
|
|
|
@ -588,8 +588,8 @@ mod tests {
|
|||
for round in 0..10 {
|
||||
for i in 0..10 {
|
||||
mut_table.add_entry(
|
||||
format!("x{}{}", i, round).into_bytes(),
|
||||
format!("value {}{}", i, round).into_bytes(),
|
||||
format!("x{i}{round}").into_bytes(),
|
||||
format!("value {i}{round}").into_bytes(),
|
||||
);
|
||||
}
|
||||
let saved_table = store.save_table(mut_table).unwrap();
|
||||
|
|
|
@ -887,11 +887,11 @@ impl TreeState {
|
|||
TreeValue::Symlink(id) => self.write_symlink(&disk_path, &path, &id)?,
|
||||
TreeValue::Conflict(id) => self.write_conflict(&disk_path, &path, &id)?,
|
||||
TreeValue::GitSubmodule(_id) => {
|
||||
println!("ignoring git submodule at {:?}", path);
|
||||
println!("ignoring git submodule at {path:?}");
|
||||
FileState::for_gitsubmodule()
|
||||
}
|
||||
TreeValue::Tree(_id) => {
|
||||
panic!("unexpected tree entry in diff at {:?}", path);
|
||||
panic!("unexpected tree entry in diff at {path:?}");
|
||||
}
|
||||
};
|
||||
self.file_states.insert(path, file_state);
|
||||
|
@ -924,11 +924,11 @@ impl TreeState {
|
|||
self.write_conflict(&disk_path, &path, &id)?
|
||||
}
|
||||
(_, TreeValue::GitSubmodule(_id)) => {
|
||||
println!("ignoring git submodule at {:?}", path);
|
||||
println!("ignoring git submodule at {path:?}");
|
||||
FileState::for_gitsubmodule()
|
||||
}
|
||||
(_, TreeValue::Tree(_id)) => {
|
||||
panic!("unexpected tree entry in diff at {:?}", path);
|
||||
panic!("unexpected tree entry in diff at {path:?}");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -965,11 +965,11 @@ impl TreeState {
|
|||
TreeValue::Symlink(_id) => FileType::Symlink,
|
||||
TreeValue::Conflict(id) => FileType::Conflict { id },
|
||||
TreeValue::GitSubmodule(_id) => {
|
||||
println!("ignoring git submodule at {:?}", path);
|
||||
println!("ignoring git submodule at {path:?}");
|
||||
FileType::GitSubmodule
|
||||
}
|
||||
TreeValue::Tree(_id) => {
|
||||
panic!("unexpected tree entry in diff at {:?}", path);
|
||||
panic!("unexpected tree entry in diff at {path:?}");
|
||||
}
|
||||
};
|
||||
let file_state = FileState {
|
||||
|
|
|
@ -223,7 +223,7 @@ fn test_subtrees(use_git: bool) {
|
|||
testutils::write_normal_file(
|
||||
&mut tree_builder,
|
||||
&RepoPath::from_internal_string(path),
|
||||
&format!("contents of {:?}", path),
|
||||
&format!("contents of {path:?}"),
|
||||
);
|
||||
}
|
||||
let tree_id = tree_builder.write_tree();
|
||||
|
@ -279,7 +279,7 @@ fn test_subtree_becomes_empty(use_git: bool) {
|
|||
testutils::write_normal_file(
|
||||
&mut tree_builder,
|
||||
&RepoPath::from_internal_string(path),
|
||||
&format!("contents of {:?}", path),
|
||||
&format!("contents of {path:?}"),
|
||||
);
|
||||
}
|
||||
let tree_id = tree_builder.write_tree();
|
||||
|
@ -310,7 +310,7 @@ fn test_subtree_one_missing(use_git: bool) {
|
|||
testutils::write_normal_file(
|
||||
&mut tree_builder,
|
||||
&RepoPath::from_internal_string(path),
|
||||
&format!("contents of {:?}", path),
|
||||
&format!("contents of {path:?}"),
|
||||
);
|
||||
}
|
||||
let tree_id = tree_builder.write_tree();
|
||||
|
@ -627,7 +627,7 @@ fn test_simplify_conflict_after_resolving_parent(use_git: bool) {
|
|||
);
|
||||
}
|
||||
other => {
|
||||
panic!("unexpected value: {:#?}", other);
|
||||
panic!("unexpected value: {other:#?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ fn test_resolve_symbol_commit_id() {
|
|||
vec![repo.store().root_commit_id().clone()],
|
||||
repo.store().empty_tree_id().clone(),
|
||||
)
|
||||
.set_description(format!("test {}", i))
|
||||
.set_description(format!("test {i}"))
|
||||
.set_author(signature.clone())
|
||||
.set_committer(signature.clone())
|
||||
.write_to_repo(mut_repo);
|
||||
|
@ -174,10 +174,10 @@ fn test_resolve_symbol_change_id() {
|
|||
for i in &[133, 664, 840, 5085] {
|
||||
let git_commit_id = git_repo
|
||||
.commit(
|
||||
Some(&format!("refs/heads/branch{}", i)),
|
||||
Some(&format!("refs/heads/branch{i}")),
|
||||
&git_author,
|
||||
&git_committer,
|
||||
&format!("test {}", i),
|
||||
&format!("test {i}"),
|
||||
&git_tree,
|
||||
&[],
|
||||
)
|
||||
|
|
|
@ -193,7 +193,7 @@ fn test_checkout_file_transitions(use_git: bool) {
|
|||
let mut files = vec![];
|
||||
for left_kind in &kinds {
|
||||
for right_kind in &kinds {
|
||||
let path = RepoPath::from_internal_string(&format!("{:?}_{:?}", left_kind, right_kind));
|
||||
let path = RepoPath::from_internal_string(&format!("{left_kind:?}_{right_kind:?}"));
|
||||
write_path(&settings, repo, &mut left_tree_builder, *left_kind, &path);
|
||||
write_path(&settings, repo, &mut right_tree_builder, *right_kind, &path);
|
||||
files.push((*left_kind, *right_kind, path));
|
||||
|
@ -221,61 +221,57 @@ fn test_checkout_file_transitions(use_git: bool) {
|
|||
let maybe_metadata = wc_path.symlink_metadata();
|
||||
match right_kind {
|
||||
Kind::Missing => {
|
||||
assert!(maybe_metadata.is_err(), "{:?} should not exist", path);
|
||||
assert!(maybe_metadata.is_err(), "{path:?} should not exist");
|
||||
}
|
||||
Kind::Normal => {
|
||||
assert!(maybe_metadata.is_ok(), "{:?} should exist", path);
|
||||
assert!(maybe_metadata.is_ok(), "{path:?} should exist");
|
||||
let metadata = maybe_metadata.unwrap();
|
||||
assert!(metadata.is_file(), "{:?} should be a file", path);
|
||||
assert!(metadata.is_file(), "{path:?} should be a file");
|
||||
#[cfg(unix)]
|
||||
assert_eq!(
|
||||
metadata.permissions().mode() & 0o111,
|
||||
0,
|
||||
"{:?} should not be executable",
|
||||
path
|
||||
"{path:?} should not be executable"
|
||||
);
|
||||
}
|
||||
Kind::Executable | Kind::ExecutableNormalContent => {
|
||||
assert!(maybe_metadata.is_ok(), "{:?} should exist", path);
|
||||
assert!(maybe_metadata.is_ok(), "{path:?} should exist");
|
||||
let metadata = maybe_metadata.unwrap();
|
||||
assert!(metadata.is_file(), "{:?} should be a file", path);
|
||||
assert!(metadata.is_file(), "{path:?} should be a file");
|
||||
#[cfg(unix)]
|
||||
assert_ne!(
|
||||
metadata.permissions().mode() & 0o111,
|
||||
0,
|
||||
"{:?} should be executable",
|
||||
path
|
||||
"{path:?} should be executable"
|
||||
);
|
||||
}
|
||||
Kind::Conflict => {
|
||||
assert!(maybe_metadata.is_ok(), "{:?} should exist", path);
|
||||
assert!(maybe_metadata.is_ok(), "{path:?} should exist");
|
||||
let metadata = maybe_metadata.unwrap();
|
||||
assert!(metadata.is_file(), "{:?} should be a file", path);
|
||||
assert!(metadata.is_file(), "{path:?} should be a file");
|
||||
#[cfg(unix)]
|
||||
assert_eq!(
|
||||
metadata.permissions().mode() & 0o111,
|
||||
0,
|
||||
"{:?} should not be executable",
|
||||
path
|
||||
"{path:?} should not be executable"
|
||||
);
|
||||
}
|
||||
Kind::Symlink => {
|
||||
assert!(maybe_metadata.is_ok(), "{:?} should exist", path);
|
||||
assert!(maybe_metadata.is_ok(), "{path:?} should exist");
|
||||
let metadata = maybe_metadata.unwrap();
|
||||
assert!(
|
||||
metadata.file_type().is_symlink(),
|
||||
"{:?} should be a symlink",
|
||||
path
|
||||
"{path:?} should be a symlink"
|
||||
);
|
||||
}
|
||||
Kind::Tree => {
|
||||
assert!(maybe_metadata.is_ok(), "{:?} should exist", path);
|
||||
assert!(maybe_metadata.is_ok(), "{path:?} should exist");
|
||||
let metadata = maybe_metadata.unwrap();
|
||||
assert!(metadata.is_dir(), "{:?} should be a directory", path);
|
||||
assert!(metadata.is_dir(), "{path:?} should be a directory");
|
||||
}
|
||||
Kind::GitSubmodule => {
|
||||
// Not supported for now
|
||||
assert!(maybe_metadata.is_err(), "{:?} should not exist", path);
|
||||
assert!(maybe_metadata.is_err(), "{path:?} should not exist");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -410,8 +406,7 @@ fn test_snapshot_racy_timestamps(use_git: bool) {
|
|||
.write(true)
|
||||
.open(&file_path)
|
||||
.unwrap();
|
||||
file.write_all(format!("contents {}", i).as_bytes())
|
||||
.unwrap();
|
||||
file.write_all(format!("contents {i}").as_bytes()).unwrap();
|
||||
}
|
||||
let mut locked_wc = wc.start_mutation();
|
||||
let new_tree_id = locked_wc.snapshot(GitIgnoreFile::empty()).unwrap();
|
||||
|
@ -729,8 +724,7 @@ fn test_gitsubmodule() {
|
|||
let file_in_submodule_path = added_submodule_path.to_fs_path(&workspace_root);
|
||||
assert!(
|
||||
file_in_submodule_path.metadata().is_ok(),
|
||||
"{:?} should exist",
|
||||
file_in_submodule_path
|
||||
"{file_in_submodule_path:?} should exist"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ fn test_checkout_parallel(use_git: bool) {
|
|||
let num_threads = max(num_cpus::get(), 4);
|
||||
let mut tree_ids = vec![];
|
||||
for i in 0..num_threads {
|
||||
let path = RepoPath::from_internal_string(format!("file{}", i).as_str());
|
||||
let path = RepoPath::from_internal_string(format!("file{i}").as_str());
|
||||
let tree = testutils::create_tree(repo, &[(&path, "contents")]);
|
||||
tree_ids.push(tree.id().clone());
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ pub fn create_random_tree(repo: &ReadonlyRepo) -> TreeId {
|
|||
.store()
|
||||
.tree_builder(repo.store().empty_tree_id().clone());
|
||||
let number = rand::random::<u32>();
|
||||
let path = RepoPath::from_internal_string(format!("file{}", number).as_str());
|
||||
let path = RepoPath::from_internal_string(format!("file{number}").as_str());
|
||||
write_normal_file(&mut tree_builder, &path, "contents");
|
||||
tree_builder.write_tree()
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ pub fn create_random_commit(settings: &UserSettings, repo: &ReadonlyRepo) -> Com
|
|||
vec![repo.store().root_commit_id().clone()],
|
||||
tree_id,
|
||||
)
|
||||
.set_description(format!("random commit {}", number))
|
||||
.set_description(format!("random commit {number}"))
|
||||
}
|
||||
|
||||
pub fn write_working_copy_file(workspace_root: &Path, path: &RepoPath, contents: &str) {
|
||||
|
@ -278,6 +278,6 @@ pub fn assert_rebased(
|
|||
);
|
||||
new_commit
|
||||
} else {
|
||||
panic!("expected rebased commit: {:?}", rebased);
|
||||
panic!("expected rebased commit: {rebased:?}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ pub fn init() {
|
|||
static CALLED: Once = Once::new();
|
||||
CALLED.call_once(|| {
|
||||
if let Err(ref e) = unsafe { platform::init() } {
|
||||
eprintln!("couldn't register signal handler: {}", e);
|
||||
eprintln!("couldn't register signal handler: {e}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ mod platform {
|
|||
let guards = &mut *LIVE_GUARDS.lock().unwrap();
|
||||
if let Err(e) = std::panic::catch_unwind(AssertUnwindSafe(|| on_signal(guards))) {
|
||||
match e.downcast::<String>() {
|
||||
Ok(s) => eprintln!("signal handler panicked: {}", s),
|
||||
Ok(s) => eprintln!("signal handler panicked: {s}"),
|
||||
Err(_) => eprintln!("signal handler panicked"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -259,7 +259,7 @@ impl CommandHelper {
|
|||
let wc_path = ui.cwd().join(wc_path_str);
|
||||
Workspace::load(ui.settings(), &wc_path, &self.store_factories).map_err(|err| match err {
|
||||
WorkspaceLoadError::NoWorkspaceHere(wc_path) => {
|
||||
let message = format!("There is no jj repo in \"{}\"", wc_path_str);
|
||||
let message = format!("There is no jj repo in \"{wc_path_str}\"");
|
||||
let git_dir = wc_path.join(".git");
|
||||
if git_dir.is_dir() {
|
||||
user_error_with_hint(
|
||||
|
@ -315,9 +315,8 @@ jj init --git-repo=.",
|
|||
if num_rebased > 0 {
|
||||
writeln!(
|
||||
ui,
|
||||
"Rebased {} descendant commits onto commits rewritten by other \
|
||||
operation",
|
||||
num_rebased
|
||||
"Rebased {num_rebased} descendant commits onto commits rewritten by \
|
||||
other operation"
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
@ -458,8 +457,8 @@ impl WorkspaceCommandHelper {
|
|||
if num_rebased > 0 {
|
||||
writeln!(
|
||||
ui,
|
||||
"Rebased {} descendant commits off of commits rewritten from git",
|
||||
num_rebased
|
||||
"Rebased {num_rebased} descendant commits off of commits rewritten from \
|
||||
git"
|
||||
)?;
|
||||
}
|
||||
self.finish_transaction(ui, tx)?;
|
||||
|
@ -613,14 +612,12 @@ impl WorkspaceCommandHelper {
|
|||
let mut iter = revset.iter().commits(self.repo.store());
|
||||
match iter.next() {
|
||||
None => Err(user_error(format!(
|
||||
"Revset \"{}\" didn't resolve to any revisions",
|
||||
revision_str
|
||||
"Revset \"{revision_str}\" didn't resolve to any revisions"
|
||||
))),
|
||||
Some(commit) => {
|
||||
if iter.next().is_some() {
|
||||
Err(user_error(format!(
|
||||
"Revset \"{}\" resolved to more than one revision",
|
||||
revision_str
|
||||
"Revset \"{revision_str}\" resolved to more than one revision"
|
||||
)))
|
||||
} else {
|
||||
Ok(commit?)
|
||||
|
@ -744,8 +741,7 @@ impl WorkspaceCommandHelper {
|
|||
if num_rebased > 0 {
|
||||
writeln!(
|
||||
ui,
|
||||
"Rebased {} descendant commits onto updated working copy",
|
||||
num_rebased
|
||||
"Rebased {num_rebased} descendant commits onto updated working copy"
|
||||
)?;
|
||||
}
|
||||
|
||||
|
@ -865,7 +861,7 @@ impl WorkspaceCommandHelper {
|
|||
}
|
||||
let num_rebased = mut_repo.rebase_descendants(ui.settings())?;
|
||||
if num_rebased > 0 {
|
||||
writeln!(ui, "Rebased {} descendant commits", num_rebased)?;
|
||||
writeln!(ui, "Rebased {num_rebased} descendant commits")?;
|
||||
}
|
||||
if self.working_copy_shared_with_git {
|
||||
self.export_head_to_git(mut_repo)?;
|
||||
|
@ -1073,8 +1069,7 @@ fn resolve_single_op_from_store(
|
|||
) -> Result<Operation, CommandError> {
|
||||
if op_str.is_empty() || !op_str.as_bytes().iter().all(|b| b.is_ascii_hexdigit()) {
|
||||
return Err(user_error(format!(
|
||||
"Operation ID \"{}\" is not a valid hexadecimal prefix",
|
||||
op_str
|
||||
"Operation ID \"{op_str}\" is not a valid hexadecimal prefix"
|
||||
)));
|
||||
}
|
||||
if let Ok(binary_op_id) = hex::decode(op_str) {
|
||||
|
@ -1100,16 +1095,12 @@ fn resolve_single_op_from_store(
|
|||
}
|
||||
}
|
||||
if matches.is_empty() {
|
||||
Err(user_error(format!(
|
||||
"No operation ID matching \"{}\"",
|
||||
op_str
|
||||
)))
|
||||
Err(user_error(format!("No operation ID matching \"{op_str}\"")))
|
||||
} else if matches.len() == 1 {
|
||||
Ok(matches.pop().unwrap())
|
||||
} else {
|
||||
Err(user_error(format!(
|
||||
"Operation ID prefix \"{}\" is ambiguous",
|
||||
op_str
|
||||
"Operation ID prefix \"{op_str}\" is ambiguous"
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
@ -1504,19 +1495,19 @@ pub fn handle_command_result(ui: &mut Ui, result: Result<(), CommandError>) -> i
|
|||
match result {
|
||||
Ok(()) => 0,
|
||||
Err(CommandError::UserError { message, hint }) => {
|
||||
ui.write_error(&format!("Error: {}\n", message)).unwrap();
|
||||
ui.write_error(&format!("Error: {message}\n")).unwrap();
|
||||
if let Some(hint) = hint {
|
||||
ui.write_hint(&format!("Hint: {}\n", hint)).unwrap();
|
||||
ui.write_hint(&format!("Hint: {hint}\n")).unwrap();
|
||||
}
|
||||
1
|
||||
}
|
||||
Err(CommandError::ConfigError(message)) => {
|
||||
ui.write_error(&format!("Config error: {}\n", message))
|
||||
ui.write_error(&format!("Config error: {message}\n"))
|
||||
.unwrap();
|
||||
1
|
||||
}
|
||||
Err(CommandError::CliError(message)) => {
|
||||
ui.write_error(&format!("Error: {}\n", message)).unwrap();
|
||||
ui.write_error(&format!("Error: {message}\n")).unwrap();
|
||||
2
|
||||
}
|
||||
Err(CommandError::ClapCliError(inner)) => {
|
||||
|
@ -1548,7 +1539,7 @@ pub fn handle_command_result(ui: &mut Ui, result: Result<(), CommandError>) -> i
|
|||
}
|
||||
Err(CommandError::BrokenPipe) => 3,
|
||||
Err(CommandError::InternalError(message)) => {
|
||||
ui.write_error(&format!("Internal error: {}\n", message))
|
||||
ui.write_error(&format!("Internal error: {message}\n"))
|
||||
.unwrap();
|
||||
255
|
||||
}
|
||||
|
|
|
@ -1216,7 +1216,7 @@ fn cmd_untrack(
|
|||
added_back.len() - 1
|
||||
)
|
||||
} else {
|
||||
format!("'{}' is not ignored.", ui_path)
|
||||
format!("'{ui_path}' is not ignored.")
|
||||
};
|
||||
return Err(user_error_with_hint(
|
||||
message,
|
||||
|
@ -1234,7 +1234,7 @@ Make sure they're ignored, then try again.",
|
|||
.write_to_repo(tx.mut_repo());
|
||||
let num_rebased = tx.mut_repo().rebase_descendants(ui.settings())?;
|
||||
if num_rebased > 0 {
|
||||
writeln!(ui, "Rebased {} descendant commits", num_rebased)?;
|
||||
writeln!(ui, "Rebased {num_rebased} descendant commits")?;
|
||||
}
|
||||
let repo = tx.commit();
|
||||
locked_working_copy.finish(repo.op_id().clone());
|
||||
|
@ -1411,7 +1411,7 @@ fn cmd_status(
|
|||
})?;
|
||||
for branch_name in conflicted_local_branches {
|
||||
write!(formatter, " ")?;
|
||||
formatter.with_label("branch", |formatter| write!(formatter, "{}", branch_name))?;
|
||||
formatter.with_label("branch", |formatter| write!(formatter, "{branch_name}"))?;
|
||||
writeln!(formatter)?;
|
||||
}
|
||||
writeln!(
|
||||
|
@ -1427,7 +1427,7 @@ fn cmd_status(
|
|||
for (branch_name, remote_name) in conflicted_remote_branches {
|
||||
write!(formatter, " ")?;
|
||||
formatter.with_label("branch", |formatter| {
|
||||
write!(formatter, "{}@{}", branch_name, remote_name)
|
||||
write!(formatter, "{branch_name}@{remote_name}")
|
||||
})?;
|
||||
writeln!(formatter)?;
|
||||
}
|
||||
|
@ -1796,7 +1796,7 @@ fn edit_description(
|
|||
description: &str,
|
||||
) -> Result<String, CommandError> {
|
||||
let random: u32 = rand::random();
|
||||
let description_file_path = repo.repo_path().join(format!("description-{}.txt", random));
|
||||
let description_file_path = repo.repo_path().join(format!("description-{random}.txt"));
|
||||
{
|
||||
let mut description_file = OpenOptions::new()
|
||||
.write(true)
|
||||
|
@ -1987,8 +1987,7 @@ fn cmd_abandon(
|
|||
if num_rebased > 0 {
|
||||
writeln!(
|
||||
ui,
|
||||
"Rebased {} descendant commits onto parents of abandoned commits",
|
||||
num_rebased
|
||||
"Rebased {num_rebased} descendant commits onto parents of abandoned commits"
|
||||
)?;
|
||||
}
|
||||
workspace_command.finish_transaction(ui, tx)?;
|
||||
|
@ -2549,7 +2548,7 @@ don't make any changes, then the operation will be aborted.
|
|||
rebaser.rebase_all()?;
|
||||
let num_rebased = rebaser.rebased().len();
|
||||
if num_rebased > 0 {
|
||||
writeln!(ui, "Rebased {} descendant commits", num_rebased)?;
|
||||
writeln!(ui, "Rebased {num_rebased} descendant commits")?;
|
||||
}
|
||||
ui.write("First part: ")?;
|
||||
write_commit_summary(
|
||||
|
@ -2628,7 +2627,7 @@ fn rebase_branch(
|
|||
num_rebased += 1;
|
||||
}
|
||||
num_rebased += tx.mut_repo().rebase_descendants(ui.settings())?;
|
||||
writeln!(ui, "Rebased {} commits", num_rebased)?;
|
||||
writeln!(ui, "Rebased {num_rebased} commits")?;
|
||||
workspace_command.finish_transaction(ui, tx)?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -2648,7 +2647,7 @@ fn rebase_descendants(
|
|||
));
|
||||
rebase_commit(ui.settings(), tx.mut_repo(), &old_commit, new_parents);
|
||||
let num_rebased = tx.mut_repo().rebase_descendants(ui.settings())? + 1;
|
||||
writeln!(ui, "Rebased {} commits", num_rebased)?;
|
||||
writeln!(ui, "Rebased {num_rebased} commits")?;
|
||||
workspace_command.finish_transaction(ui, tx)?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -2722,8 +2721,8 @@ fn rebase_revision(
|
|||
if num_rebased_descendants > 0 {
|
||||
writeln!(
|
||||
ui,
|
||||
"Also rebased {} descendant commits onto parent of rebased commit",
|
||||
num_rebased_descendants
|
||||
"Also rebased {num_rebased_descendants} descendant commits onto parent of rebased \
|
||||
commit"
|
||||
)?;
|
||||
}
|
||||
workspace_command.finish_transaction(ui, tx)?;
|
||||
|
@ -2797,7 +2796,7 @@ fn cmd_branch(
|
|||
) -> Result<(), CommandError> {
|
||||
for branch_name in names {
|
||||
if view.get_local_branch(branch_name).is_none() {
|
||||
return Err(user_error(format!("No such branch: {}", branch_name)));
|
||||
return Err(user_error(format!("No such branch: {branch_name}")));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -2836,7 +2835,7 @@ fn cmd_branch(
|
|||
.iter()
|
||||
.map(|branch_name| match view.get_local_branch(branch_name) {
|
||||
Some(_) => Err(user_error_with_hint(
|
||||
format!("Branch already exists: {}", branch_name),
|
||||
format!("Branch already exists: {branch_name}"),
|
||||
"Use `jj branch set` to update it.",
|
||||
)),
|
||||
None => Ok(branch_name.as_str()),
|
||||
|
@ -2923,7 +2922,7 @@ fn cmd_branch(
|
|||
let globbed_names = find_globs(view, glob)?;
|
||||
let names: BTreeSet<String> = names.iter().cloned().chain(globbed_names).collect();
|
||||
let branch_term = make_branch_term(names.iter().collect_vec().as_slice());
|
||||
let mut tx = workspace_command.start_transaction(&format!("forget {}", branch_term));
|
||||
let mut tx = workspace_command.start_transaction(&format!("forget {branch_term}"));
|
||||
for branch_name in names {
|
||||
tx.mut_repo().remove_branch(&branch_name);
|
||||
}
|
||||
|
@ -3001,7 +3000,7 @@ fn list_branches(
|
|||
let formatter = formatter.as_mut();
|
||||
let index = repo.index();
|
||||
for (name, branch_target) in repo.view().branches() {
|
||||
formatter.with_label("branch", |formatter| write!(formatter, "{}", name))?;
|
||||
formatter.with_label("branch", |formatter| write!(formatter, "{name}"))?;
|
||||
print_branch_target(formatter, branch_target.local_target.as_ref())?;
|
||||
|
||||
for (remote, remote_target) in branch_target
|
||||
|
@ -3013,7 +3012,7 @@ fn list_branches(
|
|||
continue;
|
||||
}
|
||||
write!(formatter, " ")?;
|
||||
formatter.with_label("branch", |formatter| write!(formatter, "@{}", remote))?;
|
||||
formatter.with_label("branch", |formatter| write!(formatter, "@{remote}"))?;
|
||||
if let Some(local_target) = branch_target.local_target.as_ref() {
|
||||
let remote_ahead_count = index
|
||||
.walk_revs(&remote_target.adds(), &local_target.adds())
|
||||
|
@ -3022,14 +3021,14 @@ fn list_branches(
|
|||
.walk_revs(&local_target.adds(), &remote_target.adds())
|
||||
.count();
|
||||
if remote_ahead_count != 0 && local_ahead_count == 0 {
|
||||
write!(formatter, " (ahead by {} commits)", remote_ahead_count)?;
|
||||
write!(formatter, " (ahead by {remote_ahead_count} commits)")?;
|
||||
} else if remote_ahead_count == 0 && local_ahead_count != 0 {
|
||||
write!(formatter, " (behind by {} commits)", local_ahead_count)?;
|
||||
write!(formatter, " (behind by {local_ahead_count} commits)")?;
|
||||
} else if remote_ahead_count != 0 && local_ahead_count != 0 {
|
||||
write!(
|
||||
formatter,
|
||||
" (ahead by {} commits, behind by {} commits)",
|
||||
remote_ahead_count, local_ahead_count
|
||||
" (ahead by {remote_ahead_count} commits, behind by {local_ahead_count} \
|
||||
commits)"
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
@ -3088,7 +3087,7 @@ fn cmd_debug(
|
|||
crate::template_parser::Rule::template,
|
||||
&template_matches.template,
|
||||
);
|
||||
writeln!(ui, "{:?}", parse)?;
|
||||
writeln!(ui, "{parse:?}")?;
|
||||
}
|
||||
DebugCommands::Index(_index_matches) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
|
@ -3100,7 +3099,7 @@ fn cmd_debug(
|
|||
writeln!(ui, "Number of changes: {}", stats.num_changes)?;
|
||||
writeln!(ui, "Stats per level:")?;
|
||||
for (i, level) in stats.levels.iter().enumerate() {
|
||||
writeln!(ui, " Level {}:", i)?;
|
||||
writeln!(ui, " Level {i}:")?;
|
||||
writeln!(ui, " Number of commits: {}", level.num_commits)?;
|
||||
writeln!(ui, " Name: {}", level.name.as_ref().unwrap())?;
|
||||
}
|
||||
|
@ -3181,7 +3180,7 @@ fn cmd_op_log(
|
|||
})?;
|
||||
for (key, value) in &metadata.tags {
|
||||
formatter.with_label("tags", |formatter| {
|
||||
formatter.write_str(&format!("\n{}: {}", key, value))
|
||||
formatter.write_str(&format!("\n{key}: {value}"))
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
|
@ -3319,8 +3318,7 @@ fn cmd_workspace_add(
|
|||
let repo = old_workspace_command.repo();
|
||||
if repo.view().get_wc_commit_id(&workspace_id).is_some() {
|
||||
return Err(user_error(format!(
|
||||
"Workspace named '{}' already exists",
|
||||
name
|
||||
"Workspace named '{name}' already exists"
|
||||
)));
|
||||
}
|
||||
let (new_workspace, repo) = Workspace::init_workspace_with_existing_repo(
|
||||
|
@ -3470,7 +3468,7 @@ fn cmd_sparse(ui: &mut Ui, command: &CommandHelper, args: &SparseArgs) -> Result
|
|||
let workspace_command = command.workspace_helper(ui)?;
|
||||
for path in workspace_command.working_copy().sparse_patterns() {
|
||||
let ui_path = workspace_command.format_file_path(path);
|
||||
writeln!(ui, "{}", ui_path)?;
|
||||
writeln!(ui, "{ui_path}")?;
|
||||
}
|
||||
} else {
|
||||
let mut workspace_command = command.workspace_helper(ui)?;
|
||||
|
@ -3781,12 +3779,11 @@ fn with_remote_callbacks<T>(ui: &mut Ui, f: impl FnOnce(git::RemoteCallbacks<'_>
|
|||
}
|
||||
|
||||
fn terminal_get_username(ui: &mut Ui, url: &str) -> Option<String> {
|
||||
ui.prompt(&format!("Username for {}", url)).ok()
|
||||
ui.prompt(&format!("Username for {url}")).ok()
|
||||
}
|
||||
|
||||
fn terminal_get_pw(ui: &mut Ui, url: &str) -> Option<String> {
|
||||
ui.prompt_password(&format!("Passphrase for {}: ", url))
|
||||
.ok()
|
||||
ui.prompt_password(&format!("Passphrase for {url}: ")).ok()
|
||||
}
|
||||
|
||||
fn pinentry_get_pw(url: &str) -> Option<String> {
|
||||
|
@ -4011,7 +4008,7 @@ fn cmd_git_push(
|
|||
let mut new_heads = vec![];
|
||||
let mut force_pushed_branches = hashset! {};
|
||||
for (branch_name, update) in &branch_updates {
|
||||
let qualified_name = format!("refs/heads/{}", branch_name);
|
||||
let qualified_name = format!("refs/heads/{branch_name}");
|
||||
if let Some(new_target) = &update.new_target {
|
||||
new_heads.push(new_target.clone());
|
||||
let force = match &update.old_target {
|
||||
|
@ -4133,17 +4130,16 @@ fn branch_updates_for_push(
|
|||
) -> Result<Option<BranchPushUpdate>, CommandError> {
|
||||
let maybe_branch_target = repo.view().get_branch(branch_name);
|
||||
let branch_target = maybe_branch_target
|
||||
.ok_or_else(|| user_error(format!("Branch {} doesn't exist", branch_name)))?;
|
||||
.ok_or_else(|| user_error(format!("Branch {branch_name} doesn't exist")))?;
|
||||
let push_action = classify_branch_push_action(branch_target, remote_name);
|
||||
|
||||
match push_action {
|
||||
BranchPushAction::AlreadyMatches => Ok(None),
|
||||
BranchPushAction::LocalConflicted => {
|
||||
Err(user_error(format!("Branch {} is conflicted", branch_name)))
|
||||
Err(user_error(format!("Branch {branch_name} is conflicted")))
|
||||
}
|
||||
BranchPushAction::RemoteConflicted => Err(user_error(format!(
|
||||
"Branch {}@{} is conflicted",
|
||||
branch_name, remote_name
|
||||
"Branch {branch_name}@{remote_name} is conflicted"
|
||||
))),
|
||||
BranchPushAction::Update(update) => Ok(Some(update)),
|
||||
}
|
||||
|
|
|
@ -332,7 +332,7 @@ pub fn show_color_words_diff(
|
|||
let right_content = diff_content(repo, &path, &right_value)?;
|
||||
let description = basic_diff_file_type(&right_value);
|
||||
formatter.with_label("header", |formatter| {
|
||||
formatter.write_str(&format!("Added {} {}:\n", description, ui_path))
|
||||
formatter.write_str(&format!("Added {description} {ui_path}:\n"))
|
||||
})?;
|
||||
show_color_words_diff_hunks(&[], &right_content, formatter)?;
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ pub fn show_color_words_diff(
|
|||
}
|
||||
};
|
||||
formatter.with_label("header", |formatter| {
|
||||
formatter.write_str(&format!("{} {}:\n", description, ui_path))
|
||||
formatter.write_str(&format!("{description} {ui_path}:\n"))
|
||||
})?;
|
||||
show_color_words_diff_hunks(&left_content, &right_content, formatter)?;
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ pub fn show_color_words_diff(
|
|||
let left_content = diff_content(repo, &path, &left_value)?;
|
||||
let description = basic_diff_file_type(&left_value);
|
||||
formatter.with_label("header", |formatter| {
|
||||
formatter.write_str(&format!("Removed {} {}:\n", description, ui_path))
|
||||
formatter.write_str(&format!("Removed {description} {ui_path}:\n"))
|
||||
})?;
|
||||
show_color_words_diff_hunks(&left_content, &[], formatter)?;
|
||||
}
|
||||
|
@ -607,11 +607,11 @@ pub fn show_git_diff(
|
|||
tree::Diff::Added(right_value) => {
|
||||
let right_part = git_diff_part(repo, &path, &right_value)?;
|
||||
formatter.with_label("file_header", |formatter| {
|
||||
writeln!(formatter, "diff --git a/{} b/{}", path_string, path_string)?;
|
||||
writeln!(formatter, "diff --git a/{path_string} b/{path_string}")?;
|
||||
writeln!(formatter, "new file mode {}", &right_part.mode)?;
|
||||
writeln!(formatter, "index 0000000000..{}", &right_part.hash)?;
|
||||
writeln!(formatter, "--- /dev/null")?;
|
||||
writeln!(formatter, "+++ b/{}", path_string)
|
||||
writeln!(formatter, "+++ b/{path_string}")
|
||||
})?;
|
||||
show_unified_diff_hunks(formatter, &[], &right_part.content)?;
|
||||
}
|
||||
|
@ -619,7 +619,7 @@ pub fn show_git_diff(
|
|||
let left_part = git_diff_part(repo, &path, &left_value)?;
|
||||
let right_part = git_diff_part(repo, &path, &right_value)?;
|
||||
formatter.with_label("file_header", |formatter| {
|
||||
writeln!(formatter, "diff --git a/{} b/{}", path_string, path_string)?;
|
||||
writeln!(formatter, "diff --git a/{path_string} b/{path_string}")?;
|
||||
if left_part.mode != right_part.mode {
|
||||
writeln!(formatter, "old mode {}", &left_part.mode)?;
|
||||
writeln!(formatter, "new mode {}", &right_part.mode)?;
|
||||
|
@ -634,8 +634,8 @@ pub fn show_git_diff(
|
|||
)?;
|
||||
}
|
||||
if left_part.content != right_part.content {
|
||||
writeln!(formatter, "--- a/{}", path_string)?;
|
||||
writeln!(formatter, "+++ b/{}", path_string)?;
|
||||
writeln!(formatter, "--- a/{path_string}")?;
|
||||
writeln!(formatter, "+++ b/{path_string}")?;
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
|
@ -644,10 +644,10 @@ pub fn show_git_diff(
|
|||
tree::Diff::Removed(left_value) => {
|
||||
let left_part = git_diff_part(repo, &path, &left_value)?;
|
||||
formatter.with_label("file_header", |formatter| {
|
||||
writeln!(formatter, "diff --git a/{} b/{}", path_string, path_string)?;
|
||||
writeln!(formatter, "diff --git a/{path_string} b/{path_string}")?;
|
||||
writeln!(formatter, "deleted file mode {}", &left_part.mode)?;
|
||||
writeln!(formatter, "index {}..0000000000", &left_part.hash)?;
|
||||
writeln!(formatter, "--- a/{}", path_string)?;
|
||||
writeln!(formatter, "--- a/{path_string}")?;
|
||||
writeln!(formatter, "+++ /dev/null")
|
||||
})?;
|
||||
show_unified_diff_hunks(formatter, &left_part.content, &[])?;
|
||||
|
|
|
@ -34,7 +34,7 @@ fn run(
|
|||
.from_env_lossy()
|
||||
})
|
||||
.map_err(|err| {
|
||||
CommandError::InternalError(format!("failed to enable verbose logging: {:?}", err))
|
||||
CommandError::InternalError(format!("failed to enable verbose logging: {err:?}"))
|
||||
})?;
|
||||
tracing::debug!("verbose logging enabled");
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ impl Progress {
|
|||
write!(self.buffer, "{: >3.0}% ", 100.0 * progress.overall).unwrap();
|
||||
if let Some(estimate) = rate {
|
||||
let (scaled, prefix) = binary_prefix(estimate);
|
||||
write!(self.buffer, " at {: >5.1} {}B/s ", scaled, prefix).unwrap();
|
||||
write!(self.buffer, " at {scaled: >5.1} {prefix}B/s ").unwrap();
|
||||
}
|
||||
|
||||
let bar_width = ui
|
||||
|
|
|
@ -47,9 +47,9 @@ fn parse_string_literal(pair: Pair<Rule>) -> String {
|
|||
'"' => result.push('"'),
|
||||
'\\' => result.push('\\'),
|
||||
'n' => result.push('\n'),
|
||||
char => panic!("invalid escape: \\{:?}", char),
|
||||
char => panic!("invalid escape: \\{char:?}"),
|
||||
},
|
||||
_ => panic!("unexpected part of string: {:?}", part),
|
||||
_ => panic!("unexpected part of string: {part:?}"),
|
||||
}
|
||||
}
|
||||
result
|
||||
|
@ -176,7 +176,7 @@ fn parse_string_method<'a>(method: Pair<Rule>) -> Property<'a, String> {
|
|||
let this_function = match name.as_str() {
|
||||
"short" => Property::String(Box::new(StringShort)),
|
||||
"first_line" => Property::String(Box::new(StringFirstLine)),
|
||||
name => panic!("no such string method: {}", name),
|
||||
name => panic!("no such string method: {name}"),
|
||||
};
|
||||
let chain_method = inner.last().unwrap();
|
||||
parse_method_chain(chain_method, this_function)
|
||||
|
@ -201,7 +201,7 @@ fn parse_commit_id_method<'a>(method: Pair<Rule>) -> Property<'a, CommitId> {
|
|||
|
||||
let this_function = match name.as_str() {
|
||||
"short" => Property::String(Box::new(CommitIdShortest)),
|
||||
name => panic!("no such commit ID method: {}", name),
|
||||
name => panic!("no such commit ID method: {name}"),
|
||||
};
|
||||
let chain_method = inner.last().unwrap();
|
||||
parse_method_chain(chain_method, this_function)
|
||||
|
@ -222,7 +222,7 @@ fn parse_signature_method<'a>(method: Pair<Rule>) -> Property<'a, Signature> {
|
|||
"name" => Property::String(Box::new(SignatureName)),
|
||||
"email" => Property::String(Box::new(SignatureEmail)),
|
||||
"timestamp" => Property::Timestamp(Box::new(SignatureTimestamp)),
|
||||
name => panic!("no such commit ID method: {}", name),
|
||||
name => panic!("no such commit ID method: {name}"),
|
||||
};
|
||||
let chain_method = inner.last().unwrap();
|
||||
parse_method_chain(chain_method, this_function)
|
||||
|
@ -236,7 +236,7 @@ fn parse_timestamp_method<'a>(method: Pair<Rule>) -> Property<'a, Timestamp> {
|
|||
|
||||
let this_function = match name.as_str() {
|
||||
"ago" => Property::String(Box::new(RelativeTimestampString)),
|
||||
name => panic!("no such timestamp method: {}", name),
|
||||
name => panic!("no such timestamp method: {name}"),
|
||||
};
|
||||
let chain_method = inner.last().unwrap();
|
||||
parse_method_chain(chain_method, this_function)
|
||||
|
@ -300,7 +300,7 @@ fn parse_commit_keyword<'a>(
|
|||
"is_git_head" => Property::Boolean(Box::new(IsGitHeadProperty::new(repo))),
|
||||
"divergent" => Property::Boolean(Box::new(DivergentProperty::new(repo))),
|
||||
"conflict" => Property::Boolean(Box::new(ConflictProperty)),
|
||||
name => panic!("unexpected identifier: {}", name),
|
||||
name => panic!("unexpected identifier: {name}"),
|
||||
};
|
||||
(property, pair.as_str().to_string())
|
||||
}
|
||||
|
@ -348,9 +348,9 @@ fn parse_boolean_commit_property<'a>(
|
|||
property,
|
||||
Box::new(|string| !string.is_empty()),
|
||||
)),
|
||||
_ => panic!("cannot yet use this as boolean: {:?}", pair),
|
||||
_ => panic!("cannot yet use this as boolean: {pair:?}"),
|
||||
},
|
||||
_ => panic!("cannot yet use this as boolean: {:?}", pair),
|
||||
_ => panic!("cannot yet use this as boolean: {pair:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -443,10 +443,10 @@ fn parse_commit_term<'a>(
|
|||
false_template,
|
||||
))
|
||||
}
|
||||
name => panic!("function {} not implemented", name),
|
||||
name => panic!("function {name} not implemented"),
|
||||
}
|
||||
}
|
||||
other => panic!("unexpected term: {:?}", other),
|
||||
other => panic!("unexpected term: {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,13 +239,13 @@ impl TemplateProperty<Commit, String> for BranchProperty<'_> {
|
|||
if let Some(local_target) = local_target {
|
||||
if local_target.has_add(context.id()) {
|
||||
if local_target.is_conflict() {
|
||||
names.push(format!("{}?", branch_name));
|
||||
names.push(format!("{branch_name}?"));
|
||||
} else if branch_target
|
||||
.remote_targets
|
||||
.values()
|
||||
.any(|remote_target| remote_target != local_target)
|
||||
{
|
||||
names.push(format!("{}*", branch_name));
|
||||
names.push(format!("{branch_name}*"));
|
||||
} else {
|
||||
names.push(branch_name.clone());
|
||||
}
|
||||
|
@ -254,9 +254,9 @@ impl TemplateProperty<Commit, String> for BranchProperty<'_> {
|
|||
for (remote_name, remote_target) in &branch_target.remote_targets {
|
||||
if Some(remote_target) != local_target && remote_target.has_add(context.id()) {
|
||||
if remote_target.is_conflict() {
|
||||
names.push(format!("{}@{}?", branch_name, remote_name));
|
||||
names.push(format!("{branch_name}@{remote_name}?"));
|
||||
} else {
|
||||
names.push(format!("{}@{}", branch_name, remote_name));
|
||||
names.push(format!("{branch_name}@{remote_name}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ impl TemplateProperty<Commit, String> for TagProperty<'_> {
|
|||
for (tag_name, target) in self.repo.view().tags() {
|
||||
if target.has_add(context.id()) {
|
||||
if target.is_conflict() {
|
||||
names.push(format!("{}?", tag_name));
|
||||
names.push(format!("{tag_name}?"));
|
||||
} else {
|
||||
names.push(tag_name.clone());
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ impl TemplateProperty<Commit, String> for GitRefsProperty<'_> {
|
|||
for (name, target) in self.repo.view().git_refs() {
|
||||
if target.has_add(context.id()) {
|
||||
if target.is_conflict() {
|
||||
names.push(format!("{}?", name));
|
||||
names.push(format!("{name}?"));
|
||||
} else {
|
||||
names.push(name.clone());
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ impl Ui {
|
|||
self.output = new_output;
|
||||
}
|
||||
Err(e) => {
|
||||
self.write_warn(&format!("Failed to spawn pager: {}\n", e))
|
||||
self.write_warn(&format!("Failed to spawn pager: {e}\n"))
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ impl Ui {
|
|||
// It's possible (though unlikely) that this write fails, but
|
||||
// this function gets called so late that there's not much we
|
||||
// can do about it.
|
||||
self.write_error(&format!("Failed to wait on pager: {}\n", e))
|
||||
self.write_error(&format!("Failed to wait on pager: {e}\n"))
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ impl Ui {
|
|||
"Cannot prompt for input since the output is not connected to a terminal",
|
||||
));
|
||||
}
|
||||
write!(self, "{}: ", prompt)?;
|
||||
write!(self, "{prompt}: ")?;
|
||||
self.flush()?;
|
||||
let mut buf = String::new();
|
||||
io::stdin().read_line(&mut buf)?;
|
||||
|
|
|
@ -94,7 +94,7 @@ fn main() {
|
|||
std::fs::write(args.after.join(file), payload).unwrap();
|
||||
}
|
||||
_ => {
|
||||
eprintln!("fake-diff-editor: unexpected command: {}", command);
|
||||
eprintln!("fake-diff-editor: unexpected command: {command}");
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ fn main() {
|
|||
std::fs::write(&args.file, payload).unwrap();
|
||||
}
|
||||
_ => {
|
||||
eprintln!("fake-editor: unexpected command: {}", command);
|
||||
eprintln!("fake-editor: unexpected command: {command}");
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,9 +165,8 @@ impl TestEnvironment {
|
|||
format!(
|
||||
r###"
|
||||
[ui]
|
||||
diff-editor = "{}"
|
||||
"###,
|
||||
escaped_diff_editor_path
|
||||
diff-editor = "{escaped_diff_editor_path}"
|
||||
"###
|
||||
)
|
||||
.as_bytes(),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue