dirstate: make DirstateItem constructor accept fallback value
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 18 Oct 2021 20:02:05 +0200
changeset 48253 948570aa7630
parent 48252 602c8e8411f5
child 48254 b874e8d81a98
dirstate: make DirstateItem constructor accept fallback value This could arguably goes in the previous changeset, but I wanted to keep that previous changeset small to focus more on the user code and the documentation. Differential Revision: https://phab.mercurial-scm.org/D11687
mercurial/cext/parsers.c
mercurial/pure/parsers.py
rust/hg-core/src/dirstate/entry.rs
rust/hg-core/src/dirstate_tree/on_disk.rs
rust/hg-cpython/src/dirstate/item.rs
--- a/mercurial/cext/parsers.c	Mon Oct 18 20:02:15 2021 +0200
+++ b/mercurial/cext/parsers.c	Mon Oct 18 20:02:05 2021 +0200
@@ -59,14 +59,12 @@
 	int size;
 	int mtime;
 	PyObject *parentfiledata;
+	PyObject *fallback_exec;
+	PyObject *fallback_symlink;
 	static char *keywords_name[] = {
-	    "wc_tracked",
-	    "p1_tracked",
-	    "p2_info",
-	    "has_meaningful_data",
-	    "has_meaningful_mtime",
-	    "parentfiledata",
-	    NULL,
+	    "wc_tracked",          "p1_tracked",           "p2_info",
+	    "has_meaningful_data", "has_meaningful_mtime", "parentfiledata",
+	    "fallback_exec",       "fallback_symlink",     NULL,
 	};
 	wc_tracked = 0;
 	p1_tracked = 0;
@@ -74,10 +72,13 @@
 	has_meaningful_mtime = 1;
 	has_meaningful_data = 1;
 	parentfiledata = Py_None;
-	if (!PyArg_ParseTupleAndKeywords(
-	        args, kwds, "|iiiiiO", keywords_name, &wc_tracked, &p1_tracked,
-	        &p2_info, &has_meaningful_data, &has_meaningful_mtime,
-	        &parentfiledata)) {
+	fallback_exec = Py_None;
+	fallback_symlink = Py_None;
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "|iiiiiOOO", keywords_name,
+	                                 &wc_tracked, &p1_tracked, &p2_info,
+	                                 &has_meaningful_data,
+	                                 &has_meaningful_mtime, &parentfiledata,
+	                                 &fallback_exec, &fallback_symlink)) {
 		return NULL;
 	}
 	t = (dirstateItemObject *)subtype->tp_alloc(subtype, 1);
@@ -96,6 +97,19 @@
 		t->flags |= dirstate_flag_p2_info;
 	}
 
+	if (fallback_exec != Py_None) {
+		t->flags |= dirstate_flag_has_fallback_exec;
+		if (PyObject_IsTrue(fallback_exec)) {
+			t->flags |= dirstate_flag_fallback_exec;
+		}
+	}
+	if (fallback_symlink != Py_None) {
+		t->flags |= dirstate_flag_has_fallback_symlink;
+		if (PyObject_IsTrue(fallback_symlink)) {
+			t->flags |= dirstate_flag_fallback_symlink;
+		}
+	}
+
 	if (parentfiledata != Py_None) {
 		if (!PyTuple_CheckExact(parentfiledata)) {
 			PyErr_SetString(
--- a/mercurial/pure/parsers.py	Mon Oct 18 20:02:15 2021 +0200
+++ b/mercurial/pure/parsers.py	Mon Oct 18 20:02:05 2021 +0200
@@ -107,13 +107,15 @@
         has_meaningful_data=True,
         has_meaningful_mtime=True,
         parentfiledata=None,
+        fallback_exec=None,
+        fallback_symlink=None,
     ):
         self._wc_tracked = wc_tracked
         self._p1_tracked = p1_tracked
         self._p2_info = p2_info
 
-        self._fallback_exec = None
-        self._fallback_symlink = None
+        self._fallback_exec = fallback_exec
+        self._fallback_symlink = fallback_symlink
 
         self._mode = None
         self._size = None
--- a/rust/hg-core/src/dirstate/entry.rs	Mon Oct 18 20:02:15 2021 +0200
+++ b/rust/hg-core/src/dirstate/entry.rs	Mon Oct 18 20:02:05 2021 +0200
@@ -183,6 +183,8 @@
         p2_info: bool,
         mode_size: Option<(u32, u32)>,
         mtime: Option<u32>,
+        fallback_exec: Option<bool>,
+        fallback_symlink: Option<bool>,
     ) -> Self {
         if let Some((mode, size)) = mode_size {
             // TODO: return an error for out of range values?
@@ -196,6 +198,18 @@
         flags.set(Flags::WDIR_TRACKED, wdir_tracked);
         flags.set(Flags::P1_TRACKED, p1_tracked);
         flags.set(Flags::P2_INFO, p2_info);
+        if let Some(exec) = fallback_exec {
+            flags.insert(Flags::HAS_FALLBACK_EXEC);
+            if exec {
+                flags.insert(Flags::FALLBACK_EXEC);
+            }
+        }
+        if let Some(exec) = fallback_symlink {
+            flags.insert(Flags::HAS_FALLBACK_SYMLINK);
+            if exec {
+                flags.insert(Flags::FALLBACK_SYMLINK);
+            }
+        }
         Self {
             flags,
             mode_size,
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs	Mon Oct 18 20:02:15 2021 +0200
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs	Mon Oct 18 20:02:05 2021 +0200
@@ -378,6 +378,8 @@
             p2_info,
             mode_size,
             mtime,
+            None,
+            None,
         )
     }
 
--- a/rust/hg-cpython/src/dirstate/item.rs	Mon Oct 18 20:02:15 2021 +0200
+++ b/rust/hg-cpython/src/dirstate/item.rs	Mon Oct 18 20:02:05 2021 +0200
@@ -23,6 +23,8 @@
         has_meaningful_data: bool = true,
         has_meaningful_mtime: bool = true,
         parentfiledata: Option<(u32, u32, u32)> = None,
+        fallback_exec: Option<bool> = None,
+        fallback_symlink: Option<bool> = None,
 
     ) -> PyResult<DirstateItem> {
         let mut mode_size_opt = None;
@@ -36,7 +38,13 @@
             }
         }
         let entry = DirstateEntry::from_v2_data(
-            wc_tracked, p1_tracked, p2_info, mode_size_opt, mtime_opt,
+            wc_tracked,
+            p1_tracked,
+            p2_info,
+            mode_size_opt,
+            mtime_opt,
+            fallback_exec,
+            fallback_symlink,
         );
         DirstateItem::create_instance(py, Cell::new(entry))
     }