Show More
@@ -5,10 +5,11 b' use crate::revlog::{Revlog, RevlogEntry,' | |||||
5 | use crate::utils::hg_path::HgPath; |
|
5 | use crate::utils::hg_path::HgPath; | |
6 | use crate::vfs::Vfs; |
|
6 | use crate::vfs::Vfs; | |
7 | use crate::{Graph, GraphError, UncheckedRevision}; |
|
7 | use crate::{Graph, GraphError, UncheckedRevision}; | |
8 | use itertools::Itertools; |
|
8 | use itertools::{Either, Itertools}; | |
9 | use std::ascii::escape_default; |
|
9 | use std::ascii::escape_default; | |
10 | use std::borrow::Cow; |
|
10 | use std::borrow::Cow; | |
11 | use std::fmt::{Debug, Formatter}; |
|
11 | use std::fmt::{Debug, Formatter}; | |
|
12 | use std::iter; | |||
12 |
|
13 | |||
13 | /// A specialized `Revlog` to work with changelog data format. |
|
14 | /// A specialized `Revlog` to work with changelog data format. | |
14 | pub struct Changelog { |
|
15 | pub struct Changelog { | |
@@ -228,9 +229,15 b" impl<'changelog> ChangelogRevisionData<'" | |||||
228 |
|
229 | |||
229 | /// The files changed in this revision. |
|
230 | /// The files changed in this revision. | |
230 | pub fn files(&self) -> impl Iterator<Item = &HgPath> { |
|
231 | pub fn files(&self) -> impl Iterator<Item = &HgPath> { | |
|
232 | if self.timestamp_end == self.files_end { | |||
|
233 | Either::Left(iter::empty()) | |||
|
234 | } else { | |||
|
235 | Either::Right( | |||
231 | self.bytes[self.timestamp_end + 1..self.files_end] |
|
236 | self.bytes[self.timestamp_end + 1..self.files_end] | |
232 | .split(|b| b == &b'\n') |
|
237 | .split(|b| b == &b'\n') | |
233 | .map(HgPath::new) |
|
238 | .map(HgPath::new), | |
|
239 | ) | |||
|
240 | } | |||
234 | } |
|
241 | } | |
235 |
|
242 | |||
236 | /// The change description. |
|
243 | /// The change description. | |
@@ -356,4 +363,12 b' message",' | |||||
356 | ); |
|
363 | ); | |
357 | Ok(()) |
|
364 | Ok(()) | |
358 | } |
|
365 | } | |
|
366 | ||||
|
367 | #[test] | |||
|
368 | fn test_empty_files_list() { | |||
|
369 | assert!(ChangelogRevisionData::null() | |||
|
370 | .files() | |||
|
371 | .collect_vec() | |||
|
372 | .is_empty()); | |||
359 | } |
|
373 | } | |
|
374 | } |
General Comments 0
You need to be logged in to leave comments.
Login now