diff -r adb367f0e9a2 -r d919b0ca8449 rust/rhg/src/commands/cat.rs --- a/rust/rhg/src/commands/cat.rs Thu Sep 30 17:34:28 2021 +0200 +++ b/rust/rhg/src/commands/cat.rs Wed Sep 01 16:13:25 2021 +0200 @@ -56,29 +56,28 @@ .map_err(|e| CommandError::abort(e.to_string()))?; files.push(hg_file); } + // TODO probably move this to a util function like `repo.default_rev` or + // something when it's used somewhere else + let rev = match rev { + Some(r) => r.to_string(), + None => format!("{:x}", repo.dirstate_parents()?.p1), + }; - match rev { - Some(rev) => { - let output = cat(&repo, rev, &files).map_err(|e| (e, rev))?; - invocation.ui.write_stdout(&output.concatenated)?; - if !output.missing.is_empty() { - let short = format!("{:x}", output.node.short()).into_bytes(); - for path in &output.missing { - invocation.ui.write_stderr(&format_bytes!( - b"{}: no such file in rev {}\n", - path.as_bytes(), - short - ))?; - } - } - if output.found_any { - Ok(()) - } else { - Err(CommandError::Unsuccessful) - } + let output = cat(&repo, &rev, &files).map_err(|e| (e, rev.as_str()))?; + invocation.ui.write_stdout(&output.concatenated)?; + if !output.missing.is_empty() { + let short = format!("{:x}", output.node.short()).into_bytes(); + for path in &output.missing { + invocation.ui.write_stderr(&format_bytes!( + b"{}: no such file in rev {}\n", + path.as_bytes(), + short + ))?; } - None => Err(CommandError::unsupported( - "`rhg cat` without `--rev` / `-r`", - )), + } + if output.found_any { + Ok(()) + } else { + Err(CommandError::Unsuccessful) } }