diff --git a/lib/src/evolution.rs b/lib/src/evolution.rs
index cac2a5a9e..d5af1fa54 100644
--- a/lib/src/evolution.rs
+++ b/lib/src/evolution.rs
@@ -13,7 +13,7 @@
// limitations under the License.
use std::collections::{HashMap, HashSet};
-use std::sync::{Arc, Mutex};
+use std::sync::{Arc, Mutex, MutexGuard};
use crate::commit::Commit;
use crate::commit_builder::CommitBuilder;
@@ -302,51 +302,55 @@ impl<'r> ReadonlyEvolution<'r> {
}
pub fn start_modification<'m>(&self, repo: &'m MutableRepo<'r>) -> MutableEvolution<'r, 'm> {
+ let locked_state = self.state.lock().unwrap();
+ let state = locked_state.as_ref().map(|state| state.as_ref().clone());
MutableEvolution {
repo,
- state: Mutex::new(self.state.lock().unwrap().clone()),
+ state: Mutex::new(state),
}
}
}
pub struct MutableEvolution<'r, 'm: 'r> {
repo: &'m MutableRepo<'r>,
- state: Mutex