diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1840,7 +1840,7 @@ class workingctx(committablectx): def _poststatusfixup(self, status, fixup): """update dirstate for files that are actually clean""" poststatus = self._repo.postdsstatus() - if fixup or poststatus: + if fixup or poststatus or self._repo.dirstate._dirty: try: oldid = self._repo.dirstate.identity() diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -1137,6 +1137,7 @@ class dirstate(object): warnings, bad, traversed, + dirty, ) = rustmod.status( self._map._rustmap, matcher, @@ -1150,6 +1151,8 @@ class dirstate(object): bool(matcher.traversedir), ) + self._dirty |= dirty + if matcher.traversedir: for dir in traversed: matcher.traversedir(dir) diff --git a/rust/hg-core/src/dirstate/status.rs b/rust/hg-core/src/dirstate/status.rs --- a/rust/hg-core/src/dirstate/status.rs +++ b/rust/hg-core/src/dirstate/status.rs @@ -293,6 +293,10 @@ pub struct DirstateStatus<'a> { /// Only filled if `collect_traversed_dirs` is `true` pub traversed: Vec>, + + /// Whether `status()` made changed to the `DirstateMap` that should be + /// written back to disk + pub dirty: bool, } #[derive(Debug, derive_more::From)] @@ -919,6 +923,7 @@ pub fn build_response<'a>( bad, unsure, traversed, + dirty: false, } } diff --git a/rust/hg-core/src/dirstate_tree/status.rs b/rust/hg-core/src/dirstate_tree/status.rs --- a/rust/hg-core/src/dirstate_tree/status.rs +++ b/rust/hg-core/src/dirstate_tree/status.rs @@ -78,8 +78,9 @@ pub fn status<'tree, 'on_disk: 'tree>( root_cached_mtime, is_at_repo_root, )?; - let outcome = common.outcome.into_inner().unwrap(); + let mut outcome = common.outcome.into_inner().unwrap(); let to_add = common.cached_directory_mtimes_to_add.into_inner().unwrap(); + outcome.dirty = !to_add.is_empty(); for (path, mtime) in &to_add { let node = DirstateMap::get_or_insert_node( dmap.on_disk, diff --git a/rust/hg-cpython/src/dirstate/status.rs b/rust/hg-cpython/src/dirstate/status.rs --- a/rust/hg-cpython/src/dirstate/status.rs +++ b/rust/hg-cpython/src/dirstate/status.rs @@ -260,6 +260,7 @@ fn build_response( let unsure = collect_pybytes_list(py, status_res.unsure.as_ref()); let bad = collect_bad_matches(py, status_res.bad.as_ref())?; let traversed = collect_pybytes_list(py, status_res.traversed.as_ref()); + let dirty = status_res.dirty.to_py_object(py); let py_warnings = PyList::new(py, &[]); for warning in warnings.iter() { // We use duck-typing on the Python side for dispatch, good enough for @@ -297,6 +298,7 @@ fn build_response( py_warnings.into_object(), bad.into_object(), traversed.into_object(), + dirty.into_object(), ][..], )) }