dirstate-v2: Write .hg/dirstate back to disk on directory cache changes
Differential Revision: https://phab.mercurial-scm.org/D10827
--- a/mercurial/context.py Fri May 28 11:48:59 2021 +0200
+++ b/mercurial/context.py Mon May 31 18:35:44 2021 +0200
@@ -1840,7 +1840,7 @@
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()
--- a/mercurial/dirstate.py Fri May 28 11:48:59 2021 +0200
+++ b/mercurial/dirstate.py Mon May 31 18:35:44 2021 +0200
@@ -1137,6 +1137,7 @@
warnings,
bad,
traversed,
+ dirty,
) = rustmod.status(
self._map._rustmap,
matcher,
@@ -1150,6 +1151,8 @@
bool(matcher.traversedir),
)
+ self._dirty |= dirty
+
if matcher.traversedir:
for dir in traversed:
matcher.traversedir(dir)
--- a/rust/hg-core/src/dirstate/status.rs Fri May 28 11:48:59 2021 +0200
+++ b/rust/hg-core/src/dirstate/status.rs Mon May 31 18:35:44 2021 +0200
@@ -293,6 +293,10 @@
/// Only filled if `collect_traversed_dirs` is `true`
pub traversed: Vec<HgPathCow<'a>>,
+
+ /// 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 @@
bad,
unsure,
traversed,
+ dirty: false,
}
}
--- a/rust/hg-core/src/dirstate_tree/status.rs Fri May 28 11:48:59 2021 +0200
+++ b/rust/hg-core/src/dirstate_tree/status.rs Mon May 31 18:35:44 2021 +0200
@@ -78,8 +78,9 @@
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,
--- a/rust/hg-cpython/src/dirstate/status.rs Fri May 28 11:48:59 2021 +0200
+++ b/rust/hg-cpython/src/dirstate/status.rs Mon May 31 18:35:44 2021 +0200
@@ -260,6 +260,7 @@
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 @@
py_warnings.into_object(),
bad.into_object(),
traversed.into_object(),
+ dirty.into_object(),
][..],
))
}