Mercurial > hg
comparison mercurial/cext/parsers.c @ 48252:602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
The concept is defined and "used" by the flag code, but it is neither persisted
nor set anywhere yet. We currently focus on defining the semantic of the
attribute. More to come in the next changesets
Check the inline documentation for details.
Differential Revision: https://phab.mercurial-scm.org/D11686
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 18 Oct 2021 20:02:15 +0200 |
parents | 1730b2fceaa1 |
children | 948570aa7630 |
comparison
equal
deleted
inserted
replaced
48251:dfc5a505ddc5 | 48252:602c8e8411f5 |
---|---|
186 } else { | 186 } else { |
187 return 'n'; | 187 return 'n'; |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 static inline bool dirstate_item_c_has_fallback_exec(dirstateItemObject *self) | |
192 { | |
193 return (bool)self->flags & dirstate_flag_has_fallback_exec; | |
194 } | |
195 | |
196 static inline bool | |
197 dirstate_item_c_has_fallback_symlink(dirstateItemObject *self) | |
198 { | |
199 return (bool)self->flags & dirstate_flag_has_fallback_symlink; | |
200 } | |
201 | |
191 static inline int dirstate_item_c_v1_mode(dirstateItemObject *self) | 202 static inline int dirstate_item_c_v1_mode(dirstateItemObject *self) |
192 { | 203 { |
193 if (self->flags & dirstate_flag_has_meaningful_data) { | 204 if (self->flags & dirstate_flag_has_meaningful_data) { |
194 return self->mode; | 205 return self->mode; |
195 } else { | 206 } else { |
496 { | 507 { |
497 char state = dirstate_item_c_v1_state(self); | 508 char state = dirstate_item_c_v1_state(self); |
498 return PyBytes_FromStringAndSize(&state, 1); | 509 return PyBytes_FromStringAndSize(&state, 1); |
499 }; | 510 }; |
500 | 511 |
512 static PyObject *dirstate_item_get_has_fallback_exec(dirstateItemObject *self) | |
513 { | |
514 if (dirstate_item_c_has_fallback_exec(self)) { | |
515 Py_RETURN_TRUE; | |
516 } else { | |
517 Py_RETURN_FALSE; | |
518 } | |
519 }; | |
520 | |
521 static PyObject *dirstate_item_get_fallback_exec(dirstateItemObject *self) | |
522 { | |
523 if (dirstate_item_c_has_fallback_exec(self)) { | |
524 if (self->flags & dirstate_flag_fallback_exec) { | |
525 Py_RETURN_TRUE; | |
526 } else { | |
527 Py_RETURN_FALSE; | |
528 } | |
529 } else { | |
530 Py_RETURN_NONE; | |
531 } | |
532 }; | |
533 | |
534 static int dirstate_item_set_fallback_exec(dirstateItemObject *self, | |
535 PyObject *value) | |
536 { | |
537 if ((value == Py_None) || (value == NULL)) { | |
538 self->flags &= ~dirstate_flag_has_fallback_exec; | |
539 } else { | |
540 self->flags |= dirstate_flag_has_fallback_exec; | |
541 if (PyObject_IsTrue(value)) { | |
542 self->flags |= dirstate_flag_fallback_exec; | |
543 } else { | |
544 self->flags &= ~dirstate_flag_fallback_exec; | |
545 } | |
546 } | |
547 return 0; | |
548 }; | |
549 | |
550 static PyObject * | |
551 dirstate_item_get_has_fallback_symlink(dirstateItemObject *self) | |
552 { | |
553 if (dirstate_item_c_has_fallback_symlink(self)) { | |
554 Py_RETURN_TRUE; | |
555 } else { | |
556 Py_RETURN_FALSE; | |
557 } | |
558 }; | |
559 | |
560 static PyObject *dirstate_item_get_fallback_symlink(dirstateItemObject *self) | |
561 { | |
562 if (dirstate_item_c_has_fallback_symlink(self)) { | |
563 if (self->flags & dirstate_flag_fallback_symlink) { | |
564 Py_RETURN_TRUE; | |
565 } else { | |
566 Py_RETURN_FALSE; | |
567 } | |
568 } else { | |
569 Py_RETURN_NONE; | |
570 } | |
571 }; | |
572 | |
573 static int dirstate_item_set_fallback_symlink(dirstateItemObject *self, | |
574 PyObject *value) | |
575 { | |
576 if ((value == Py_None) || (value == NULL)) { | |
577 self->flags &= ~dirstate_flag_has_fallback_symlink; | |
578 } else { | |
579 self->flags |= dirstate_flag_has_fallback_symlink; | |
580 if (PyObject_IsTrue(value)) { | |
581 self->flags |= dirstate_flag_fallback_symlink; | |
582 } else { | |
583 self->flags &= ~dirstate_flag_fallback_symlink; | |
584 } | |
585 } | |
586 return 0; | |
587 }; | |
588 | |
501 static PyObject *dirstate_item_get_tracked(dirstateItemObject *self) | 589 static PyObject *dirstate_item_get_tracked(dirstateItemObject *self) |
502 { | 590 { |
503 if (dirstate_item_c_tracked(self)) { | 591 if (dirstate_item_c_tracked(self)) { |
504 Py_RETURN_TRUE; | 592 Py_RETURN_TRUE; |
505 } else { | 593 } else { |
586 static PyGetSetDef dirstate_item_getset[] = { | 674 static PyGetSetDef dirstate_item_getset[] = { |
587 {"mode", (getter)dirstate_item_get_mode, NULL, "mode", NULL}, | 675 {"mode", (getter)dirstate_item_get_mode, NULL, "mode", NULL}, |
588 {"size", (getter)dirstate_item_get_size, NULL, "size", NULL}, | 676 {"size", (getter)dirstate_item_get_size, NULL, "size", NULL}, |
589 {"mtime", (getter)dirstate_item_get_mtime, NULL, "mtime", NULL}, | 677 {"mtime", (getter)dirstate_item_get_mtime, NULL, "mtime", NULL}, |
590 {"state", (getter)dirstate_item_get_state, NULL, "state", NULL}, | 678 {"state", (getter)dirstate_item_get_state, NULL, "state", NULL}, |
679 {"has_fallback_exec", (getter)dirstate_item_get_has_fallback_exec, NULL, | |
680 "has_fallback_exec", NULL}, | |
681 {"fallback_exec", (getter)dirstate_item_get_fallback_exec, | |
682 (setter)dirstate_item_set_fallback_exec, "fallback_exec", NULL}, | |
683 {"has_fallback_symlink", (getter)dirstate_item_get_has_fallback_symlink, | |
684 NULL, "has_fallback_symlink", NULL}, | |
685 {"fallback_symlink", (getter)dirstate_item_get_fallback_symlink, | |
686 (setter)dirstate_item_set_fallback_symlink, "fallback_symlink", NULL}, | |
591 {"tracked", (getter)dirstate_item_get_tracked, NULL, "tracked", NULL}, | 687 {"tracked", (getter)dirstate_item_get_tracked, NULL, "tracked", NULL}, |
592 {"p1_tracked", (getter)dirstate_item_get_p1_tracked, NULL, "p1_tracked", | 688 {"p1_tracked", (getter)dirstate_item_get_p1_tracked, NULL, "p1_tracked", |
593 NULL}, | 689 NULL}, |
594 {"added", (getter)dirstate_item_get_added, NULL, "added", NULL}, | 690 {"added", (getter)dirstate_item_get_added, NULL, "added", NULL}, |
595 {"p2_info", (getter)dirstate_item_get_p2_info, NULL, "p2_info", NULL}, | 691 {"p2_info", (getter)dirstate_item_get_p2_info, NULL, "p2_info", NULL}, |