D11464: dirstate: Remove the `state == ' '` special case
SimonSapin
phabricator at mercurial-scm.org
Mon Sep 20 22:19:51 UTC 2021
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
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.
REPOSITORY
rHG Mercurial
BRANCH
default
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
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list