Mercurial > hg
diff rust/rhg/src/commands/cat.rs @ 48237:027ebad952ac
rhg: internally, return a structured representation from hg cat
The purpose of this change is to make it possible to support limited templating in `hg cat`, so we could print separators between files etc.
The templating itself is not implemented yet, so this functionality is unused in `rhg cat`.
However, in our fork of hg we're implementing a slightly different command `hg jscat` which makes use of this.
So accepting this change will let us minimize the size of the patch we're maintaining on our side.
Differential Revision: https://phab.mercurial-scm.org/D11679
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Fri, 15 Oct 2021 14:05:20 +0100 |
parents | 6b5773f89183 |
children | 698b70b9e8ea |
line wrap: on
line diff
--- a/rust/rhg/src/commands/cat.rs Thu Oct 14 19:02:08 2021 +0100 +++ b/rust/rhg/src/commands/cat.rs Fri Oct 15 14:05:20 2021 +0100 @@ -66,6 +66,7 @@ .map_err(|e| CommandError::abort(e.to_string()))?; files.push(hg_file); } + let files = files.iter().map(|file| file.as_ref()).collect(); // TODO probably move this to a util function like `repo.default_rev` or // something when it's used somewhere else let rev = match rev { @@ -74,7 +75,9 @@ }; let output = cat(&repo, &rev, files).map_err(|e| (e, rev.as_str()))?; - invocation.ui.write_stdout(&output.concatenated)?; + for (_file, contents) in output.results { + invocation.ui.write_stdout(&contents)?; + } if !output.missing.is_empty() { let short = format!("{:x}", output.node.short()).into_bytes(); for path in &output.missing {