Skip to content
Snippets Groups Projects
Commit 3eac9250 authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

dirstate-entry: add `modified` property

This was already done in the Rust implementation and is a useful primitive.
The C implementation had this called `merged`, but wasn't used anywhere.

It will be used in the next changeset.
parent b1e4c74b
No related branches found
No related tags found
2 merge requests!485branching: merge default into stable,!363Make `hg verify` also check the dirstate
......@@ -177,7 +177,7 @@
(dirstate_flag_p1_tracked | dirstate_flag_p2_info));
}
static inline bool dirstate_item_c_merged(dirstateItemObject *self)
static inline bool dirstate_item_c_modified(dirstateItemObject *self)
{
return ((self->flags & dirstate_flag_wc_tracked) &&
(self->flags & dirstate_flag_p1_tracked) &&
......@@ -195,7 +195,7 @@
{
if (dirstate_item_c_removed(self)) {
return 'r';
} else if (dirstate_item_c_merged(self)) {
} else if (dirstate_item_c_modified(self)) {
return 'm';
} else if (dirstate_item_c_added(self)) {
return 'a';
......@@ -642,5 +642,5 @@
}
};
static PyObject *dirstate_item_get_merged(dirstateItemObject *self)
static PyObject *dirstate_item_get_modified(dirstateItemObject *self)
{
......@@ -646,5 +646,5 @@
{
if (dirstate_item_c_merged(self)) {
if (dirstate_item_c_modified(self)) {
Py_RETURN_TRUE;
} else {
Py_RETURN_FALSE;
......@@ -709,7 +709,7 @@
NULL},
{"added", (getter)dirstate_item_get_added, NULL, "added", NULL},
{"p2_info", (getter)dirstate_item_get_p2_info, NULL, "p2_info", NULL},
{"merged", (getter)dirstate_item_get_merged, NULL, "merged", NULL},
{"modified", (getter)dirstate_item_get_modified, NULL, "modified", NULL},
{"from_p2", (getter)dirstate_item_get_from_p2, NULL, "from_p2", NULL},
{"maybe_clean", (getter)dirstate_item_get_maybe_clean, NULL, "maybe_clean",
NULL},
......@@ -1187,7 +1187,7 @@
void manifest_module_init(PyObject *mod);
void revlog_module_init(PyObject *mod);
static const int version = 20;
static const int version = 21;
static void module_init(PyObject *mod)
{
......
......@@ -76,7 +76,7 @@
('cext', 'bdiff'): 3,
('cext', 'mpatch'): 1,
('cext', 'osutil'): 4,
('cext', 'parsers'): 20,
('cext', 'parsers'): 21,
}
# map import request to other package or module
......
......@@ -435,6 +435,11 @@
return self._wc_tracked and not (self._p1_tracked or self._p2_info)
@property
def modified(self):
"""True if the file has been modified"""
return self._wc_tracked and self._p1_tracked and self._p2_info
@property
def maybe_clean(self):
"""True if the file has a chance to be in the "clean" state"""
if not self._wc_tracked:
......
......@@ -151,6 +151,10 @@
Ok(self.entry(py).get().added())
}
@property
def modified(&self) -> PyResult<bool> {
Ok(self.entry(py).get().modified())
}
@property
def p2_info(&self) -> PyResult<bool> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment