changeset 48025:631f6b445a77

dirstate: Remove the `state == ' '` special case Previously this was used to create a `DirstateItem` representing dirstate tree nodes that semantically don’t have an associated `DirtateItem`. This isn’t used anymore now that `dirstatemap.debug_iter` yields plain tuples. Differential Revision: https://phab.mercurial-scm.org/D11464
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 20 Sep 2021 20:21:35 +0200
parents cedfe2606adf
children 1b2ee68e85f9
files mercurial/cext/parsers.c mercurial/cext/util.h rust/hg-cpython/src/dirstate.rs
diffstat 3 files changed, 9 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/parsers.c	Mon Sep 20 20:20:55 2021 +0200
+++ b/mercurial/cext/parsers.c	Mon Sep 20 20:21:35 2021 +0200
@@ -192,9 +192,7 @@
 
 static inline char dirstate_item_c_v1_state(dirstateItemObject *self)
 {
-	if (self->flags & dirstate_flag_rust_special) {
-		return ' ';
-	} else if (dirstate_item_c_removed(self)) {
+	if (dirstate_item_c_removed(self)) {
 		return 'r';
 	} else if (dirstate_item_c_merged(self)) {
 		return 'm';
@@ -212,9 +210,7 @@
 
 static inline int dirstate_item_c_v1_size(dirstateItemObject *self)
 {
-	if (self->flags & dirstate_flag_rust_special) {
-		return self->size;
-	} else if (dirstate_item_c_merged_removed(self)) {
+	if (dirstate_item_c_merged_removed(self)) {
 		return dirstate_v1_nonnormal;
 	} else if (dirstate_item_c_from_p2_removed(self)) {
 		return dirstate_v1_from_p2;
@@ -235,9 +231,7 @@
 
 static inline int dirstate_item_c_v1_mtime(dirstateItemObject *self)
 {
-	if (self->flags & dirstate_flag_rust_special) {
-		return self->mtime;
-	} else if (dirstate_item_c_removed(self)) {
+	if (dirstate_item_c_removed(self)) {
 		return 0;
 	} else if (self->flags & dirstate_flag_possibly_dirty) {
 		return ambiguous_time;
@@ -354,13 +348,6 @@
 			t->size = size;
 			t->mtime = mtime;
 		}
-	} else if (state == ' ') {
-		/* XXX Rust is using this special case, it should be clean up
-		 * later. */
-		t->flags = dirstate_flag_rust_special;
-		t->mode = mode;
-		t->size = size;
-		t->mtime = mtime;
 	} else {
 		PyErr_Format(PyExc_RuntimeError,
 		             "unknown state: `%c` (%d, %d, %d)", state, mode,
--- a/mercurial/cext/util.h	Mon Sep 20 20:20:55 2021 +0200
+++ b/mercurial/cext/util.h	Mon Sep 20 20:21:35 2021 +0200
@@ -38,7 +38,6 @@
 static const unsigned char dirstate_flag_merged = 1 << 4;
 static const unsigned char dirstate_flag_clean_p1 = 1 << 5;
 static const unsigned char dirstate_flag_clean_p2 = 1 << 6;
-static const unsigned char dirstate_flag_rust_special = 1 << 7;
 
 extern PyTypeObject dirstateItemType;
 #define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstateItemType)
--- a/rust/hg-cpython/src/dirstate.rs	Mon Sep 20 20:20:55 2021 +0200
+++ b/rust/hg-cpython/src/dirstate.rs	Mon Sep 20 20:21:35 2021 +0200
@@ -52,25 +52,15 @@
     // because Into<u8> has a specific implementation while `as c_char` would
     // just do a naive enum cast.
     let state_code: u8 = entry.state().into();
-    make_dirstate_item_raw(
-        py,
-        state_code,
-        entry.mode(),
-        entry.size(),
-        entry.mtime(),
-    )
-}
 
-pub fn make_dirstate_item_raw(
-    py: Python,
-    state: u8,
-    mode: i32,
-    size: i32,
-    mtime: i32,
-) -> PyResult<PyObject> {
     let make = make_dirstate_item_capi::retrieve(py)?;
     let maybe_obj = unsafe {
-        let ptr = make(state as c_char, mode, size, mtime);
+        let ptr = make(
+            state_code as c_char,
+            entry.mode(),
+            entry.size(),
+            entry.mtime(),
+        );
         PyObject::from_owned_ptr_opt(py, ptr)
     };
     maybe_obj.ok_or_else(|| PyErr::fetch(py))