D10966: dirstate: no longer pass the `oldstate` value to the dirstatemap
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Sun Jul 4 21:55:31 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
The dirstatemap already have this information.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10966
AFFECTED 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
CHANGE DETAILS
diff --git a/rust/hg-cpython/src/dirstate/dispatch.rs b/rust/hg-cpython/src/dirstate/dispatch.rs
--- a/rust/hg-cpython/src/dirstate/dispatch.rs
+++ b/rust/hg-cpython/src/dirstate/dispatch.rs
@@ -24,18 +24,12 @@
fn add_file(
&mut self,
filename: &HgPath,
- old_state: EntryState,
entry: DirstateEntry,
from_p2: bool,
possibly_dirty: bool,
) -> Result<(), DirstateError> {
- self.get_mut().add_file(
- filename,
- old_state,
- entry,
- from_p2,
- possibly_dirty,
- )
+ self.get_mut()
+ .add_file(filename, entry, from_p2, possibly_dirty)
}
fn remove_file(
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
@@ -108,7 +108,6 @@
def addfile(
&self,
f: PyObject,
- oldstate: PyObject,
state: PyObject,
mode: PyObject,
size: PyObject,
@@ -118,11 +117,6 @@
) -> PyResult<PyObject> {
let f = f.extract::<PyBytes>(py)?;
let filename = HgPath::new(f.data(py));
- let oldstate = oldstate.extract::<PyBytes>(py)?.data(py)[0]
- .try_into()
- .map_err(|e: HgError| {
- PyErr::new::<exc::ValueError, _>(py, e.to_string())
- })?;
let state = state.extract::<PyBytes>(py)?.data(py)[0]
.try_into()
.map_err(|e: HgError| {
@@ -151,7 +145,6 @@
let possibly_dirty = possibly_dirty.extract::<PyBool>(py)?.is_true();
self.inner(py).borrow_mut().add_file(
filename,
- oldstate,
entry,
from_p2,
possibly_dirty
diff --git a/rust/hg-core/src/dirstate_tree/dispatch.rs b/rust/hg-core/src/dirstate_tree/dispatch.rs
--- a/rust/hg-core/src/dirstate_tree/dispatch.rs
+++ b/rust/hg-core/src/dirstate_tree/dispatch.rs
@@ -47,7 +47,6 @@
fn add_file(
&mut self,
filename: &HgPath,
- old_state: EntryState,
entry: DirstateEntry,
from_p2: bool,
possibly_dirty: bool,
@@ -287,12 +286,11 @@
fn add_file(
&mut self,
filename: &HgPath,
- old_state: EntryState,
entry: DirstateEntry,
from_p2: bool,
possibly_dirty: bool,
) -> Result<(), DirstateError> {
- self.add_file(filename, old_state, entry, from_p2, possibly_dirty)
+ self.add_file(filename, entry, from_p2, possibly_dirty)
}
fn remove_file(
diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -721,7 +721,6 @@
fn add_file(
&mut self,
filename: &HgPath,
- old_state: EntryState,
entry: DirstateEntry,
from_p2: bool,
possibly_dirty: bool,
@@ -744,6 +743,11 @@
entry.mtime = entry.mtime & V1_RANGEMASK;
}
+ let old_state = match self.get(filename)? {
+ Some(e) => e.state,
+ None => EntryState::Unknown,
+ };
+
Ok(self.add_or_remove_file(filename, old_state, entry)?)
}
diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -68,7 +68,6 @@
pub fn add_file(
&mut self,
filename: &HgPath,
- old_state: EntryState,
entry: DirstateEntry,
// XXX once the dust settle this should probably become an enum
from_p2: bool,
@@ -91,7 +90,10 @@
entry.size = entry.size & V1_RANGEMASK;
entry.mtime = entry.mtime & V1_RANGEMASK;
}
-
+ let old_state = match self.get(filename) {
+ Some(e) => e.state,
+ None => EntryState::Unknown,
+ };
if old_state == EntryState::Unknown || old_state == EntryState::Removed
{
if let Some(ref mut dirs) = self.dirs {
@@ -397,7 +399,6 @@
map.add_file(
HgPath::new(b"meh"),
- EntryState::Normal,
DirstateEntry {
state: EntryState::Normal,
mode: 1337,
diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -147,7 +147,6 @@
def addfile(
self,
f,
- oldstate,
state,
mode,
size=None,
@@ -175,9 +174,12 @@
mtime = mtime & rangemask
assert size is not None
assert mtime is not None
- if oldstate in b"?r" and "_dirs" in self.__dict__:
+ old_entry = self.get(f)
+ if (
+ old_entry is None or old_entry.removed
+ ) and "_dirs" in self.__dict__:
self._dirs.addpath(f)
- if oldstate == b"?" and "_alldirs" in self.__dict__:
+ if old_entry is None and "_alldirs" in self.__dict__:
self._alldirs.addpath(f)
self._map[f] = dirstatetuple(state, mode, size, mtime)
if state != b'n' or mtime == AMBIGUOUS_TIME:
@@ -459,7 +461,6 @@
def addfile(
self,
f,
- oldstate,
state,
mode,
size=None,
@@ -469,7 +470,6 @@
):
return self._rustmap.addfile(
f,
- oldstate,
state,
mode,
size,
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -450,7 +450,6 @@
from_p2=False,
possibly_dirty=False,
):
- oldstate = self[f]
entry = self._map.get(f)
if state == b'a' or entry is not None and entry.removed:
scmutil.checkfilename(f)
@@ -471,7 +470,6 @@
self._updatedfiles.add(f)
self._map.addfile(
f,
- oldstate,
state=state,
mode=mode,
size=size,
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list