[Updated] D10368: dirstate-tree: Add parsing only dirstate parents from disk

SimonSapin phabricator at mercurial-scm.org
Thu May 6 16:50:32 UTC 2021


Closed by commit rHG12182be26285: dirstate-tree: Add parsing only dirstate parents from disk (authored by SimonSapin).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D10368?vs=27051&id=27642

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D10368/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D10368

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -3,8 +3,9 @@
 use std::time::Duration;
 
 use super::path_with_basename::WithBasename;
+use crate::dirstate::parsers::parse_dirstate_entries;
+use crate::dirstate::parsers::parse_dirstate_parents;
 
-use crate::dirstate::parsers::parse_dirstate_entries;
 use crate::matchers::Matcher;
 use crate::revlog::node::NULL_NODE;
 use crate::utils::hg_path::{HgPath, HgPathBuf};
@@ -175,9 +176,20 @@
 
     fn parents(
         &mut self,
-        _file_contents: &[u8],
+        file_contents: &[u8],
     ) -> Result<&DirstateParents, DirstateError> {
-        todo!()
+        if self.parents.is_none() {
+            let parents = if !file_contents.is_empty() {
+                parse_dirstate_parents(file_contents)?.clone()
+            } else {
+                DirstateParents {
+                    p1: NULL_NODE,
+                    p2: NULL_NODE,
+                }
+            };
+            self.parents = Some(parents);
+        }
+        Ok(self.parents.as_ref().unwrap())
     }
 
     fn set_parents(&mut self, parents: &DirstateParents) {



To: SimonSapin, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210506/25175095/attachment.html>


More information about the Mercurial-patches mailing list