rust-repo: don't use on-disk dirstate parents in v1
authorRaphaël Gomès <rgomes@octobus.net>
Wed, 02 Oct 2024 13:36:51 +0200
changeset 52047 e1fe336c007a
parent 52046 28a0eb21ff04
child 52048 78fc666a3e94
rust-repo: don't use on-disk dirstate parents in v1 This mistake was not causing any problems yet since we were never updating parents from Rust code. This is about to change, so let's fix it.
rust/hg-core/src/repo.rs
--- a/rust/hg-core/src/repo.rs	Tue Oct 01 13:45:18 2024 +0200
+++ b/rust/hg-core/src/repo.rs	Wed Oct 02 13:36:51 2024 +0200
@@ -450,11 +450,14 @@
         debug_wait_for_file_or_print(self.config(), "dirstate.pre-read-file");
         let identity = self.dirstate_identity()?;
         let dirstate_file_contents = self.dirstate_file_contents()?;
+        let parents = self.dirstate_parents()?;
         if dirstate_file_contents.is_empty() {
-            self.dirstate_parents.set(DirstateParents::NULL);
+            self.dirstate_parents.set(parents);
             Ok(OwningDirstateMap::new_empty(Vec::new(), identity))
         } else {
-            let (map, parents) =
+            // Ignore the dirstate on-disk parents, they may have been set in
+            // the repo before
+            let (map, _) =
                 OwningDirstateMap::new_v1(dirstate_file_contents, identity)?;
             self.dirstate_parents.set(parents);
             Ok(map)