[Commented On] D12450: dirstatemap: move `set_tracked` out of common methods and plug in Rust
baymax (Baymax, Your Personal Patch-care Companion)
phabricator at mercurial-scm.org
Tue Apr 12 14:57:27 UTC 2022
baymax added a comment.
baymax updated this revision to Diff 33024.
✅ refresh by Heptapod after a successful CI run (🐙 💚)
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12450?vs=32922&id=33024
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D12450/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D12450
AFFECTED FILES
mercurial/dirstatemap.py
rust/hg-cpython/src/dirstate/dirstate_map.rs
CHANGE DETAILS
diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs b/rust/hg-cpython/src/dirstate/dirstate_map.rs
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -131,6 +131,16 @@
Ok(PyNone)
}
+ def set_tracked(&self, f: PyObject) -> PyResult<PyBool> {
+ let bytes = f.extract::<PyBytes>(py)?;
+ let path = HgPath::new(bytes.data(py));
+ let res = self.inner(py).borrow_mut().set_tracked(path);
+ let was_tracked = res.or_else(|_| {
+ Err(PyErr::new::<exc::OSError, _>(py, "Dirstate error".to_string()))
+ })?;
+ Ok(was_tracked.to_py_object(py))
+ }
+
def removefile(
&self,
f: PyObject,
diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -130,30 +130,6 @@
self._refresh_entry(filename, entry)
self.copymap.pop(filename, None)
- def set_tracked(self, filename):
- new = False
- entry = self.get(filename)
- if entry is None:
- self._dirs_incr(filename)
- entry = DirstateItem(
- wc_tracked=True,
- )
-
- self._insert_entry(filename, entry)
- new = True
- elif not entry.tracked:
- self._dirs_incr(filename, entry)
- entry.set_tracked()
- self._refresh_entry(filename, entry)
- new = True
- else:
- # XXX This is probably overkill for more case, but we need this to
- # fully replace the `normallookup` call with `set_tracked` one.
- # Consider smoothing this in the future.
- entry.set_possibly_dirty()
- self._refresh_entry(filename, entry)
- return new
-
def set_untracked(self, f):
"""Mark a file as no longer tracked in the dirstate map"""
entry = self.get(f)
@@ -538,6 +514,30 @@
### code related to manipulation of entries and copy-sources
+ def set_tracked(self, filename):
+ new = False
+ entry = self.get(filename)
+ if entry is None:
+ self._dirs_incr(filename)
+ entry = DirstateItem(
+ wc_tracked=True,
+ )
+
+ self._insert_entry(filename, entry)
+ new = True
+ elif not entry.tracked:
+ self._dirs_incr(filename, entry)
+ entry.set_tracked()
+ self._refresh_entry(filename, entry)
+ new = True
+ else:
+ # XXX This is probably overkill for more case, but we need this to
+ # fully replace the `normallookup` call with `set_tracked` one.
+ # Consider smoothing this in the future.
+ entry.set_possibly_dirty()
+ self._refresh_entry(filename, entry)
+ return new
+
def _refresh_entry(self, f, entry):
if not entry.any_tracked:
self._map.pop(f, None)
@@ -722,6 +722,9 @@
def _insert_entry(self, f, entry):
self._map.addfile(f, entry)
+ def set_tracked(self, f):
+ return self._map.set_tracked(f)
+
def _drop_entry(self, f):
self._map.drop_item_and_copy_source(f)
To: Alphare, #hg-reviewers, marmoute
Cc: marmoute, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220412/27c20bd5/attachment-0002.html>
More information about the Mercurial-patches
mailing list