[Request] [++ ] D11579: dirstate-item: implement `drop_merge_data` on the Rust DirstateItem
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Sat Oct 2 15:06:14 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
It was currently missing and we want to be able to use in it the Rust case too.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D11579
AFFECTED FILES
rust/hg-core/src/dirstate/entry.rs
rust/hg-cpython/src/dirstate/item.rs
CHANGE DETAILS
diff --git a/rust/hg-cpython/src/dirstate/item.rs b/rust/hg-cpython/src/dirstate/item.rs
--- a/rust/hg-cpython/src/dirstate/item.rs
+++ b/rust/hg-cpython/src/dirstate/item.rs
@@ -166,6 +166,11 @@
DirstateItem::create_instance(py, Cell::new(entry))
}
+ def drop_merge_data(&self) -> PyResult<PyNone> {
+ self.update(py, |entry| entry.drop_merge_data());
+ Ok(PyNone)
+ }
+
def set_clean(
&self,
mode: i32,
diff --git a/rust/hg-core/src/dirstate/entry.rs b/rust/hg-core/src/dirstate/entry.rs
--- a/rust/hg-core/src/dirstate/entry.rs
+++ b/rust/hg-core/src/dirstate/entry.rs
@@ -263,6 +263,33 @@
}
}
+ pub fn drop_merge_data(&mut self) {
+ if self.flags.contains(Flags::CLEAN_P1)
+ || self.flags.contains(Flags::CLEAN_P2)
+ || self.flags.contains(Flags::MERGED)
+ || self.flags.contains(Flags::P2_TRACKED)
+ {
+ if self.flags.contains(Flags::MERGED) {
+ self.flags.insert(Flags::P1_TRACKED);
+ } else {
+ self.flags.remove(Flags::P1_TRACKED);
+ }
+ self.flags.remove(
+ Flags::MERGED
+ | Flags::CLEAN_P1
+ | Flags::CLEAN_P2
+ | Flags::P2_TRACKED,
+ );
+ self.flags.insert(Flags::POSSIBLY_DIRTY);
+ self.mode = 0;
+ self.mtime = 0;
+ // size = None on the python size turn into size = NON_NORMAL when
+ // accessed. So the next line is currently required, but a some
+ // future clean up would be welcome.
+ self.size = SIZE_NON_NORMAL;
+ }
+ }
+
pub fn set_possibly_dirty(&mut self) {
self.flags.insert(Flags::POSSIBLY_DIRTY)
}
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20211002/c00afa62/attachment-0001.html>
More information about the Mercurial-patches
mailing list