##// END OF EJS Templates
dirstate-item: introduce a `maybe_clean` property...
marmoute -
r48898:80783e55 default
parent child Browse files
Show More
@@ -620,6 +620,21 b' static PyObject *dirstate_item_get_from_'
620 620 }
621 621 };
622 622
623 static PyObject *dirstate_item_get_maybe_clean(dirstateItemObject *self)
624 {
625 if (!(self->flags & dirstate_flag_wc_tracked)) {
626 Py_RETURN_FALSE;
627 } else if (dirstate_item_c_added(self)) {
628 Py_RETURN_FALSE;
629 } else if (self->flags & dirstate_flag_merged) {
630 Py_RETURN_FALSE;
631 } else if (self->flags & dirstate_flag_clean_p2) {
632 Py_RETURN_FALSE;
633 } else {
634 Py_RETURN_TRUE;
635 }
636 };
637
623 638 static PyObject *dirstate_item_get_removed(dirstateItemObject *self)
624 639 {
625 640 if (dirstate_item_c_removed(self)) {
@@ -638,6 +653,8 b' static PyGetSetDef dirstate_item_getset['
638 653 {"added", (getter)dirstate_item_get_added, NULL, "added", NULL},
639 654 {"merged", (getter)dirstate_item_get_merged, NULL, "merged", NULL},
640 655 {"from_p2", (getter)dirstate_item_get_from_p2, NULL, "from_p2", NULL},
656 {"maybe_clean", (getter)dirstate_item_get_maybe_clean, NULL, "maybe_clean",
657 NULL},
641 658 {"removed", (getter)dirstate_item_get_removed, NULL, "removed", NULL},
642 659 {NULL} /* Sentinel */
643 660 };
@@ -319,6 +319,19 b' class DirstateItem(object):'
319 319 return self._wc_tracked and not (self._p1_tracked or self._p2_tracked)
320 320
321 321 @property
322 def maybe_clean(self):
323 """True if the file has a chance to be in the "clean" state"""
324 if not self._wc_tracked:
325 return False
326 elif self.added:
327 return False
328 elif self._merged:
329 return False
330 elif self._clean_p2:
331 return False
332 return True
333
334 @property
322 335 def merged(self):
323 336 """True if the file has been merged
324 337
@@ -191,6 +191,20 b' impl DirstateEntry {'
191 191 self.flags.contains(Flags::WDIR_TRACKED | Flags::CLEAN_P2)
192 192 }
193 193
194 pub fn maybe_clean(&self) -> bool {
195 if !self.flags.contains(Flags::WDIR_TRACKED) {
196 false
197 } else if self.added() {
198 false
199 } else if self.flags.contains(Flags::MERGED) {
200 false
201 } else if self.flags.contains(Flags::CLEAN_P2) {
202 false
203 } else {
204 true
205 }
206 }
207
194 208 pub fn state(&self) -> EntryState {
195 209 if self.removed() {
196 210 EntryState::Removed
@@ -85,6 +85,11 b' py_class!(pub class DirstateItem |py| {'
85 85 Ok(self.entry(py).get().from_p2())
86 86 }
87 87
88 @property
89 def maybe_clean(&self) -> PyResult<bool> {
90 Ok(self.entry(py).get().maybe_clean())
91 }
92
88 93 def v1_state(&self) -> PyResult<PyBytes> {
89 94 let (state, _mode, _size, _mtime) = self.entry(py).get().v1_data();
90 95 let state_byte: u8 = state.into();
General Comments 0
You need to be logged in to leave comments. Login now