mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
dag: replace 2 panics with non-panic errors
Summary: The panics can happen when the input sets are out of range. Reviewed By: kulshrax Differential Revision: D24191789 fbshipit-source-id: efbcbd7f6f69bd262aa979afa4f44acf9681d11e
This commit is contained in:
parent
83c996cf95
commit
9ed54f1b94
@ -676,9 +676,10 @@ impl<Store: IdDagStore> IdDag<Store> {
|
||||
|
||||
// A flat segment contains information to calculate
|
||||
// parents(subset of the segment).
|
||||
let seg = self.find_flat_segment_including_id(head)?.expect(
|
||||
"logic error: flat segments are expected to cover everything but they do not",
|
||||
);
|
||||
let seg = match self.find_flat_segment_including_id(head)? {
|
||||
Some(seg) => seg,
|
||||
None => return head.not_found(),
|
||||
};
|
||||
let seg_span = seg.span()?;
|
||||
let seg_low = seg_span.low;
|
||||
let seg_set: SpanSet = seg_span.into();
|
||||
@ -712,9 +713,10 @@ impl<Store: IdDagStore> IdDag<Store> {
|
||||
|
||||
/// Get parents of a single `id`. Preserve the order.
|
||||
pub fn parent_ids(&self, id: Id) -> Result<Vec<Id>> {
|
||||
let seg = self
|
||||
.find_flat_segment_including_id(id)?
|
||||
.expect("logic error: flat segments are expected to cover everything but they do not");
|
||||
let seg = match self.find_flat_segment_including_id(id)? {
|
||||
Some(seg) => seg,
|
||||
None => return id.not_found(),
|
||||
};
|
||||
let span = seg.span()?;
|
||||
if id == span.low {
|
||||
Ok(seg.parents()?)
|
||||
|
Loading…
Reference in New Issue
Block a user