cli: print "Added X files, modified Y files, removed Z files" on all updates

I was confused myself why the message was only printed by `jj co` and
not e.g. `jj undo`. That probably means that it should always be
printed (or never be printed).
This commit is contained in:
Martin von Zweigbergk 2021-11-17 21:49:27 -08:00
parent 6c0f3625ff
commit 83c051984e

View file

@ -427,7 +427,15 @@ impl RepoCommandHelper {
}
}
self.repo = tx.commit();
update_working_copy(ui, &self.repo, &mut self.repo.working_copy_locked())
let stats = update_working_copy(ui, &self.repo, &mut self.repo.working_copy_locked())?;
if let Some(stats) = &stats {
writeln!(
ui,
"Added {} files, modified {} files, removed {} files",
stats.added_files, stats.updated_files, stats.removed_files
)?;
}
Ok(stats)
}
}
@ -1383,13 +1391,8 @@ fn cmd_checkout(
repo_command.start_transaction(&format!("check out commit {}", new_commit.id().hex()));
tx.mut_repo().check_out(ui.settings(), &new_commit);
let stats = repo_command.finish_transaction(ui, tx)?;
match stats {
None => ui.write("Already on that commit\n")?,
Some(stats) => writeln!(
ui,
"Added {} files, modified {} files, removed {} files",
stats.added_files, stats.updated_files, stats.removed_files
)?,
if stats.is_none() {
ui.write("Already on that commit\n")?;
}
Ok(())
}