Mercurial > hg
comparison rust/hg-core/src/filepatterns.rs @ 42634:0247601869ba
rust-filepatterns: fix type of warnings tuple to (bytes, bytes)
Otherwise warn() in match.py would fail if the warning contains non-ASCII
character.
We might want to add a thin ByteString wrapper around Vec<u8> to
implement ToPyObject<ObjectType = PyBytes>, but I'm not sure.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 21 Jul 2019 12:46:57 +0900 |
parents | 326fdce22fb2 |
children | 30f8e786868c |
comparison
equal
deleted
inserted
replaced
42633:f78f305454fd | 42634:0247601869ba |
---|---|
225 m | 225 m |
226 }; | 226 }; |
227 } | 227 } |
228 | 228 |
229 pub type PatternTuple = (Vec<u8>, LineNumber, Vec<u8>); | 229 pub type PatternTuple = (Vec<u8>, LineNumber, Vec<u8>); |
230 type WarningTuple = (String, String); | 230 type WarningTuple = (Vec<u8>, Vec<u8>); |
231 | 231 |
232 pub fn parse_pattern_file_contents( | 232 pub fn parse_pattern_file_contents( |
233 lines: &[u8], | 233 lines: &[u8], |
234 file_path: &[u8], | 234 file_path: &[u8], |
235 warn: bool, | 235 warn: bool, |
261 let syntax = line[b"syntax:".len()..].trim(); | 261 let syntax = line[b"syntax:".len()..].trim(); |
262 | 262 |
263 if let Some(rel_syntax) = SYNTAXES.get(syntax) { | 263 if let Some(rel_syntax) = SYNTAXES.get(syntax) { |
264 current_syntax = rel_syntax; | 264 current_syntax = rel_syntax; |
265 } else if warn { | 265 } else if warn { |
266 warnings.push(( | 266 warnings.push((file_path.to_owned(), syntax.to_owned())); |
267 String::from_utf8_lossy(file_path).to_string(), | |
268 String::from_utf8_lossy(syntax).to_string(), | |
269 )); | |
270 } | 267 } |
271 continue; | 268 continue; |
272 } | 269 } |
273 | 270 |
274 let mut line_syntax: &[u8] = ¤t_syntax; | 271 let mut line_syntax: &[u8] = ¤t_syntax; |