##// END OF EJS Templates
dirstate-item: introduce a `any_tracked` property...
marmoute -
r48899:79bc60ca default
parent child Browse files
Show More
@@ -635,6 +635,18 b' static PyObject *dirstate_item_get_maybe'
635 }
635 }
636 };
636 };
637
637
638 static PyObject *dirstate_item_get_any_tracked(dirstateItemObject *self)
639 {
640 unsigned char mask = dirstate_flag_wc_tracked |
641 dirstate_flag_p1_tracked |
642 dirstate_flag_p2_tracked;
643 if ((self->flags & mask) != 0) {
644 Py_RETURN_TRUE;
645 } else {
646 Py_RETURN_FALSE;
647 }
648 };
649
638 static PyObject *dirstate_item_get_removed(dirstateItemObject *self)
650 static PyObject *dirstate_item_get_removed(dirstateItemObject *self)
639 {
651 {
640 if (dirstate_item_c_removed(self)) {
652 if (dirstate_item_c_removed(self)) {
@@ -655,6 +667,8 b' static PyGetSetDef dirstate_item_getset['
655 {"from_p2", (getter)dirstate_item_get_from_p2, NULL, "from_p2", NULL},
667 {"from_p2", (getter)dirstate_item_get_from_p2, NULL, "from_p2", NULL},
656 {"maybe_clean", (getter)dirstate_item_get_maybe_clean, NULL, "maybe_clean",
668 {"maybe_clean", (getter)dirstate_item_get_maybe_clean, NULL, "maybe_clean",
657 NULL},
669 NULL},
670 {"any_tracked", (getter)dirstate_item_get_any_tracked, NULL, "any_tracked",
671 NULL},
658 {"removed", (getter)dirstate_item_get_removed, NULL, "removed", NULL},
672 {"removed", (getter)dirstate_item_get_removed, NULL, "removed", NULL},
659 {NULL} /* Sentinel */
673 {NULL} /* Sentinel */
660 };
674 };
@@ -314,6 +314,11 b' class DirstateItem(object):'
314 return self._wc_tracked
314 return self._wc_tracked
315
315
316 @property
316 @property
317 def any_tracked(self):
318 """True is the file is tracked anywhere (wc or parents)"""
319 return self._wc_tracked or self._p1_tracked or self._p2_tracked
320
321 @property
317 def added(self):
322 def added(self):
318 """True if the file has been added"""
323 """True if the file has been added"""
319 return self._wc_tracked and not (self._p1_tracked or self._p2_tracked)
324 return self._wc_tracked and not (self._p1_tracked or self._p2_tracked)
@@ -205,6 +205,12 b' impl DirstateEntry {'
205 }
205 }
206 }
206 }
207
207
208 pub fn any_tracked(&self) -> bool {
209 self.flags.intersects(
210 Flags::WDIR_TRACKED | Flags::P1_TRACKED | Flags::P2_TRACKED,
211 )
212 }
213
208 pub fn state(&self) -> EntryState {
214 pub fn state(&self) -> EntryState {
209 if self.removed() {
215 if self.removed() {
210 EntryState::Removed
216 EntryState::Removed
@@ -90,6 +90,11 b' py_class!(pub class DirstateItem |py| {'
90 Ok(self.entry(py).get().maybe_clean())
90 Ok(self.entry(py).get().maybe_clean())
91 }
91 }
92
92
93 @property
94 def any_tracked(&self) -> PyResult<bool> {
95 Ok(self.entry(py).get().any_tracked())
96 }
97
93 def v1_state(&self) -> PyResult<PyBytes> {
98 def v1_state(&self) -> PyResult<PyBytes> {
94 let (state, _mode, _size, _mtime) = self.entry(py).get().v1_data();
99 let (state, _mode, _size, _mtime) = self.entry(py).get().v1_data();
95 let state_byte: u8 = state.into();
100 let state_byte: u8 = state.into();
General Comments 0
You need to be logged in to leave comments. Login now