cli: use pager for print

The `print` command shows the contents of a file, so that is obviously
often more than a page long. Both `hg cat file` and `git show
HEAD:file` page the output.
This commit is contained in:
Martin von Zweigbergk 2022-12-04 06:18:38 -08:00 committed by Martin von Zweigbergk
parent 8e994a28fe
commit dc8830843e

View file

@ -1263,12 +1263,14 @@ fn cmd_print(ui: &mut Ui, command: &CommandHelper, args: &PrintArgs) -> Result<(
}
Some(TreeValue::File { id, .. }) => {
let mut contents = repo.store().read_file(&path, &id)?;
ui.request_pager();
std::io::copy(&mut contents, &mut ui.stdout_formatter().as_mut())?;
}
Some(TreeValue::Conflict(id)) => {
let conflict = repo.store().read_conflict(&path, &id)?;
let mut contents = vec![];
conflicts::materialize_conflict(repo.store(), &path, &conflict, &mut contents).unwrap();
ui.request_pager();
ui.stdout_formatter().write_all(&contents)?;
}
_ => {