forked from mirrors/jj
evolution: don't crash when commit is no longer in view's set of heads
If you rewrite a change twice, from A to A' to A'', then undo the operation that created A', you'll end up with a repo where A'' refers to commit (A') that's not reachable from any head in the view. We currently crash when that happens. This change fixes the crash. Undoing the A' operation now instead produces a state where A and A'' are divergent. That at least makes some sense. This may not seem important since I'm working on removing support for evolution (#32), but I wanted to get it fixed in order to help with the transition off of evolution. Specifically, I want to be able to start removing old heads more freely. This closes #28.
This commit is contained in:
parent
de5bf90675
commit
e1fd69cfa8
1 changed files with 5 additions and 3 deletions
|
@ -101,9 +101,11 @@ impl State {
|
|||
work.extend(state.pruned_commits.iter().cloned());
|
||||
while !work.is_empty() {
|
||||
let commit_id = work.pop().unwrap();
|
||||
for child in state.children.get(&commit_id).unwrap() {
|
||||
if state.orphan_commits.insert(child.clone()) {
|
||||
work.push(child.clone());
|
||||
if let Some(children) = state.children.get(&commit_id) {
|
||||
for child in children {
|
||||
if state.orphan_commits.insert(child.clone()) {
|
||||
work.push(child.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue