Show More
@@ -16,6 +16,8 b' use crate::revlog::revlog::RevlogError;' | |||
|
16 | 16 | use crate::revlog::Revision; |
|
17 | 17 | use crate::utils::hg_path::HgPathBuf; |
|
18 | 18 | |
|
19 | const METADATA_DELIMITER: [u8; 2] = [b'\x01', b'\n']; | |
|
20 | ||
|
19 | 21 | /// Kind of error encountered by `CatRev` |
|
20 | 22 | #[derive(Debug)] |
|
21 | 23 | pub enum CatRevErrorKind { |
@@ -132,10 +134,21 b" impl<'a> CatRev<'a> {" | |||
|
132 | 134 | .map_err(|_| CatRevErrorKind::CorruptedRevlog)?; |
|
133 | 135 | let file_rev = file_log.get_node_rev(&file_node)?; |
|
134 | 136 | let data = file_log.get_rev_data(file_rev)?; |
|
137 | if data.starts_with(&METADATA_DELIMITER) { | |
|
138 | let end_delimiter_position = data | |
|
139 | [METADATA_DELIMITER.len()..] | |
|
140 | .windows(METADATA_DELIMITER.len()) | |
|
141 | .position(|bytes| bytes == METADATA_DELIMITER); | |
|
142 | if let Some(position) = end_delimiter_position { | |
|
143 | let offset = METADATA_DELIMITER.len() * 2; | |
|
144 | bytes.extend(data[position + offset..].iter()); | |
|
145 | } | |
|
146 | } else { | |
|
135 | 147 | bytes.extend(data); |
|
136 | 148 | } |
|
137 | 149 | } |
|
138 | 150 | } |
|
151 | } | |
|
139 | 152 | |
|
140 | 153 | Ok(bytes) |
|
141 | 154 | } else { |
@@ -90,3 +90,19 b' Debuging data in inline index' | |||
|
90 | 90 | file1\x00b8e02f6433738021a065f94175c7cd23db5f05be (esc) |
|
91 | 91 | file2\x005d9299349fc01ddd25d0070d149b124d8f10411e (esc) |
|
92 | 92 | file3\x002661d26c649684b482d10f91960cc3db683c38b4 (esc) |
|
93 | ||
|
94 | Cat files | |
|
95 | $ cd $TESTTMP | |
|
96 | $ rm -rf repository | |
|
97 | $ hg init repository | |
|
98 | $ cd repository | |
|
99 | $ echo "original content" > original | |
|
100 | $ hg add original | |
|
101 | $ hg commit -m "add original" original | |
|
102 | $ rhg cat -r 0 original | |
|
103 | original content | |
|
104 | Cat copied file should not display copy metadata | |
|
105 | $ hg copy original copy_of_original | |
|
106 | $ hg commit -m "add copy of original" | |
|
107 | $ rhg cat -r 1 copy_of_original | |
|
108 | original content |
General Comments 0
You need to be logged in to leave comments.
Login now