##// END OF EJS Templates
dirstate: Remove the `state == ' '` special case...
Simon Sapin -
r48837:631f6b44 default
parent child Browse files
Show More
@@ -192,9 +192,7 b' static inline bool dirstate_item_c_from_'
192
192
193 static inline char dirstate_item_c_v1_state(dirstateItemObject *self)
193 static inline char dirstate_item_c_v1_state(dirstateItemObject *self)
194 {
194 {
195 if (self->flags & dirstate_flag_rust_special) {
195 if (dirstate_item_c_removed(self)) {
196 return ' ';
197 } else if (dirstate_item_c_removed(self)) {
198 return 'r';
196 return 'r';
199 } else if (dirstate_item_c_merged(self)) {
197 } else if (dirstate_item_c_merged(self)) {
200 return 'm';
198 return 'm';
@@ -212,9 +210,7 b' static inline int dirstate_item_c_v1_mod'
212
210
213 static inline int dirstate_item_c_v1_size(dirstateItemObject *self)
211 static inline int dirstate_item_c_v1_size(dirstateItemObject *self)
214 {
212 {
215 if (self->flags & dirstate_flag_rust_special) {
213 if (dirstate_item_c_merged_removed(self)) {
216 return self->size;
217 } else if (dirstate_item_c_merged_removed(self)) {
218 return dirstate_v1_nonnormal;
214 return dirstate_v1_nonnormal;
219 } else if (dirstate_item_c_from_p2_removed(self)) {
215 } else if (dirstate_item_c_from_p2_removed(self)) {
220 return dirstate_v1_from_p2;
216 return dirstate_v1_from_p2;
@@ -235,9 +231,7 b' static inline int dirstate_item_c_v1_siz'
235
231
236 static inline int dirstate_item_c_v1_mtime(dirstateItemObject *self)
232 static inline int dirstate_item_c_v1_mtime(dirstateItemObject *self)
237 {
233 {
238 if (self->flags & dirstate_flag_rust_special) {
234 if (dirstate_item_c_removed(self)) {
239 return self->mtime;
240 } else if (dirstate_item_c_removed(self)) {
241 return 0;
235 return 0;
242 } else if (self->flags & dirstate_flag_possibly_dirty) {
236 } else if (self->flags & dirstate_flag_possibly_dirty) {
243 return ambiguous_time;
237 return ambiguous_time;
@@ -354,13 +348,6 b' dirstate_item_from_v1_data(char state, i'
354 t->size = size;
348 t->size = size;
355 t->mtime = mtime;
349 t->mtime = mtime;
356 }
350 }
357 } else if (state == ' ') {
358 /* XXX Rust is using this special case, it should be clean up
359 * later. */
360 t->flags = dirstate_flag_rust_special;
361 t->mode = mode;
362 t->size = size;
363 t->mtime = mtime;
364 } else {
351 } else {
365 PyErr_Format(PyExc_RuntimeError,
352 PyErr_Format(PyExc_RuntimeError,
366 "unknown state: `%c` (%d, %d, %d)", state, mode,
353 "unknown state: `%c` (%d, %d, %d)", state, mode,
@@ -38,7 +38,6 b' static const unsigned char dirstate_flag'
38 static const unsigned char dirstate_flag_merged = 1 << 4;
38 static const unsigned char dirstate_flag_merged = 1 << 4;
39 static const unsigned char dirstate_flag_clean_p1 = 1 << 5;
39 static const unsigned char dirstate_flag_clean_p1 = 1 << 5;
40 static const unsigned char dirstate_flag_clean_p2 = 1 << 6;
40 static const unsigned char dirstate_flag_clean_p2 = 1 << 6;
41 static const unsigned char dirstate_flag_rust_special = 1 << 7;
42
41
43 extern PyTypeObject dirstateItemType;
42 extern PyTypeObject dirstateItemType;
44 #define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstateItemType)
43 #define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstateItemType)
@@ -52,25 +52,15 b' pub fn make_dirstate_item('
52 // because Into<u8> has a specific implementation while `as c_char` would
52 // because Into<u8> has a specific implementation while `as c_char` would
53 // just do a naive enum cast.
53 // just do a naive enum cast.
54 let state_code: u8 = entry.state().into();
54 let state_code: u8 = entry.state().into();
55 make_dirstate_item_raw(
55
56 py,
56 let make = make_dirstate_item_capi::retrieve(py)?;
57 state_code,
57 let maybe_obj = unsafe {
58 let ptr = make(
59 state_code as c_char,
58 entry.mode(),
60 entry.mode(),
59 entry.size(),
61 entry.size(),
60 entry.mtime(),
62 entry.mtime(),
61 )
63 );
62 }
63
64 pub fn make_dirstate_item_raw(
65 py: Python,
66 state: u8,
67 mode: i32,
68 size: i32,
69 mtime: i32,
70 ) -> PyResult<PyObject> {
71 let make = make_dirstate_item_capi::retrieve(py)?;
72 let maybe_obj = unsafe {
73 let ptr = make(state as c_char, mode, size, mtime);
74 PyObject::from_owned_ptr_opt(py, ptr)
64 PyObject::from_owned_ptr_opt(py, ptr)
75 };
65 };
76 maybe_obj.ok_or_else(|| PyErr::fetch(py))
66 maybe_obj.ok_or_else(|| PyErr::fetch(py))
General Comments 0
You need to be logged in to leave comments. Login now