[Updated] D11464: dirstate: Remove the `state == ' '` special case

SimonSapin phabricator at mercurial-scm.org
Wed Sep 22 08:55:52 UTC 2021


Closed by commit rHG631f6b445a77: dirstate: Remove the `state == ' '` special case (authored by SimonSapin).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D11464?vs=30338&id=30376

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

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

AFFECTED FILES
  mercurial/cext/parsers.c
  mercurial/cext/util.h
  rust/hg-cpython/src/dirstate.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate.rs b/rust/hg-cpython/src/dirstate.rs
--- a/rust/hg-cpython/src/dirstate.rs
+++ b/rust/hg-cpython/src/dirstate.rs
@@ -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))
diff --git a/mercurial/cext/util.h b/mercurial/cext/util.h
--- a/mercurial/cext/util.h
+++ b/mercurial/cext/util.h
@@ -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)
diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -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,



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


More information about the Mercurial-patches mailing list