Mercurial > hg
changeset 47527:c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Differential Revision: https://phab.mercurial-scm.org/D10969
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 04 Jul 2021 01:48:11 +0200 |
parents | 8bcae9bf9e8d |
children | 80617f3c0f9a |
files | mercurial/dirstate.py mercurial/dirstatemap.py rust/hg-core/src/dirstate/dirstate_map.rs rust/hg-core/src/dirstate_tree/dirstate_map.rs rust/hg-core/src/dirstate_tree/dispatch.rs rust/hg-cpython/src/dirstate/dirstate_map.rs rust/hg-cpython/src/dirstate/dispatch.rs |
diffstat | 7 files changed, 37 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dirstate.py Sun Jul 04 01:44:43 2021 +0200 +++ b/mercurial/dirstate.py Sun Jul 04 01:48:11 2021 +0200 @@ -448,6 +448,7 @@ size=None, mtime=None, added=False, + merged=False, from_p2=False, possibly_dirty=False, ): @@ -476,6 +477,7 @@ size=size, mtime=mtime, added=added, + merged=merged, from_p2=from_p2, possibly_dirty=possibly_dirty, ) @@ -538,7 +540,7 @@ raise error.Abort(msg) if f in self and self[f] == b'n': # merge-like - self._addpath(f, b'm', 0, from_p2=True) + self._addpath(f, merged=True) else: # add-like self._addpath(f, b'n', 0, from_p2=True)
--- a/mercurial/dirstatemap.py Sun Jul 04 01:44:43 2021 +0200 +++ b/mercurial/dirstatemap.py Sun Jul 04 01:48:11 2021 +0200 @@ -152,16 +152,24 @@ size=None, mtime=None, added=False, + merged=False, from_p2=False, possibly_dirty=False, ): """Add a tracked file to the dirstate.""" if added: + assert not merged assert not possibly_dirty assert not from_p2 state = b'a' size = NONNORMAL mtime = AMBIGUOUS_TIME + elif merged: + assert not possibly_dirty + assert not from_p2 + state = b'm' + size = FROM_P2 + mtime = AMBIGUOUS_TIME elif from_p2: assert not possibly_dirty size = FROM_P2 @@ -470,6 +478,7 @@ size=None, mtime=None, added=False, + merged=False, from_p2=False, possibly_dirty=False, ): @@ -480,6 +489,7 @@ size, mtime, added, + merged, from_p2, possibly_dirty, )
--- a/rust/hg-core/src/dirstate/dirstate_map.rs Sun Jul 04 01:44:43 2021 +0200 +++ b/rust/hg-core/src/dirstate/dirstate_map.rs Sun Jul 04 01:48:11 2021 +0200 @@ -71,16 +71,24 @@ entry: DirstateEntry, // XXX once the dust settle this should probably become an enum added: bool, + merged: bool, from_p2: bool, possibly_dirty: bool, ) -> Result<(), DirstateError> { let mut entry = entry; if added { + assert!(!merged); assert!(!possibly_dirty); assert!(!from_p2); entry.state = EntryState::Added; entry.size = SIZE_NON_NORMAL; entry.mtime = MTIME_UNSET; + } else if merged { + assert!(!possibly_dirty); + assert!(!from_p2); + entry.state = EntryState::Merged; + entry.size = SIZE_FROM_OTHER_PARENT; + entry.mtime = MTIME_UNSET; } else if from_p2 { assert!(!possibly_dirty); entry.size = SIZE_FROM_OTHER_PARENT; @@ -410,6 +418,7 @@ false, false, false, + false, ) .unwrap();
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs Sun Jul 04 01:44:43 2021 +0200 +++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs Sun Jul 04 01:48:11 2021 +0200 @@ -723,6 +723,7 @@ filename: &HgPath, entry: DirstateEntry, added: bool, + merged: bool, from_p2: bool, possibly_dirty: bool, ) -> Result<(), DirstateError> { @@ -733,6 +734,12 @@ entry.state = EntryState::Added; entry.size = SIZE_NON_NORMAL; entry.mtime = MTIME_UNSET; + } else if merged { + assert!(!possibly_dirty); + assert!(!from_p2); + entry.state = EntryState::Merged; + entry.size = SIZE_FROM_OTHER_PARENT; + entry.mtime = MTIME_UNSET; } else if from_p2 { assert!(!possibly_dirty); entry.size = SIZE_FROM_OTHER_PARENT;
--- a/rust/hg-core/src/dirstate_tree/dispatch.rs Sun Jul 04 01:44:43 2021 +0200 +++ b/rust/hg-core/src/dirstate_tree/dispatch.rs Sun Jul 04 01:48:11 2021 +0200 @@ -49,6 +49,7 @@ filename: &HgPath, entry: DirstateEntry, added: bool, + merged: bool, from_p2: bool, possibly_dirty: bool, ) -> Result<(), DirstateError>; @@ -289,10 +290,11 @@ filename: &HgPath, entry: DirstateEntry, added: bool, + merged: bool, from_p2: bool, possibly_dirty: bool, ) -> Result<(), DirstateError> { - self.add_file(filename, entry, added, from_p2, possibly_dirty) + self.add_file(filename, entry, added, merged, from_p2, possibly_dirty) } fn remove_file(
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs Sun Jul 04 01:44:43 2021 +0200 +++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs Sun Jul 04 01:48:11 2021 +0200 @@ -113,6 +113,7 @@ size: PyObject, mtime: PyObject, added: PyObject, + merged: PyObject, from_p2: PyObject, possibly_dirty: PyObject, ) -> PyResult<PyObject> { @@ -153,12 +154,14 @@ mtime: mtime, }; let added = added.extract::<PyBool>(py)?.is_true(); + let merged = merged.extract::<PyBool>(py)?.is_true(); let from_p2 = from_p2.extract::<PyBool>(py)?.is_true(); let possibly_dirty = possibly_dirty.extract::<PyBool>(py)?.is_true(); self.inner(py).borrow_mut().add_file( filename, entry, added, + merged, from_p2, possibly_dirty ).and(Ok(py.None())).or_else(|e: DirstateError| {
--- a/rust/hg-cpython/src/dirstate/dispatch.rs Sun Jul 04 01:44:43 2021 +0200 +++ b/rust/hg-cpython/src/dirstate/dispatch.rs Sun Jul 04 01:48:11 2021 +0200 @@ -26,6 +26,7 @@ filename: &HgPath, entry: DirstateEntry, added: bool, + merged: bool, from_p2: bool, possibly_dirty: bool, ) -> Result<(), DirstateError> { @@ -33,6 +34,7 @@ filename, entry, added, + merged, from_p2, possibly_dirty, )