Read about our upcoming Code of Conduct on this issue

This instance was upgraded to Heptapod 0.28.0 today

Commit 0d09530c authored by Pierre-Yves David's avatar Pierre-Yves David 🐙
Browse files

dirstate: remove `lastnormaltime` mechanism

This is now redundant with the new, simpler `mtime_boundary` one.

Differential Revision: https://phab.mercurial-scm.org/D11795
parent 322525db4c98
......@@ -116,7 +116,6 @@ class dirstate(object):
# UNC path pointing to root share (issue4557)
self._rootdir = pathutil.normasprefix(root)
self._dirty = False
self._lastnormaltime = timestamp.zero()
self._ui = ui
self._filecache = {}
self._parentwriters = 0
......@@ -430,7 +429,6 @@ class dirstate(object):
for a in ("_map", "_branch", "_ignore"):
if a in self.__dict__:
delattr(self, a)
self._lastnormaltime = timestamp.zero()
self._dirty = False
self._parentwriters = 0
self._origpl = None
......@@ -493,11 +491,6 @@ class dirstate(object):
self._check_new_tracked_filename(filename)
(mode, size, mtime) = parentfiledata
self._map.set_clean(filename, mode, size, mtime)
if mtime > self._lastnormaltime:
# Remember the most recent modification timeslot for status(),
# to make sure we won't miss future size-preserving file content
# modifications that happen within the same timeslot.
self._lastnormaltime = mtime
@requires_no_parents_change
def set_possibly_dirty(self, filename):
......@@ -581,15 +574,6 @@ class dirstate(object):
has_meaningful_mtime=not possibly_dirty,
parentfiledata=parentfiledata,
)
if (
parentfiledata is not None
and parentfiledata[2] is not None
and parentfiledata[2] > self._lastnormaltime
):
# Remember the most recent modification timeslot for status(),
# to make sure we won't miss future size-preserving file content
# modifications that happen within the same timeslot.
self._lastnormaltime = parentfiledata[2]
def _check_new_tracked_filename(self, filename):
scmutil.checkfilename(filename)
......@@ -693,7 +677,6 @@ class dirstate(object):
def clear(self):
self._map.clear()
self._lastnormaltime = timestamp.zero()
self._dirty = True
def rebuild(self, parent, allfiles, changedfiles=None):
......@@ -701,9 +684,7 @@ class dirstate(object):
# Rebuild entire dirstate
to_lookup = allfiles
to_drop = []
lastnormaltime = self._lastnormaltime
self.clear()
self._lastnormaltime = lastnormaltime
elif len(changedfiles) < 10:
# Avoid turning allfiles into a set, which can be expensive if it's
# large.
......@@ -818,7 +799,6 @@ class dirstate(object):
break
self._map.write(tr, st, now)
self._lastnormaltime = timestamp.zero()
self._dirty = False
def _dirignore(self, f):
......@@ -1216,7 +1196,6 @@ class dirstate(object):
self._rootdir,
self._ignorefiles(),
self._checkexec,
self._lastnormaltime,
bool(list_clean),
bool(list_ignored),
bool(list_unknown),
......@@ -1343,7 +1322,6 @@ class dirstate(object):
checkexec = self._checkexec
checklink = self._checklink
copymap = self._map.copymap
lastnormaltime = self._lastnormaltime
# We need to do full walks when either
# - we're listing all clean files, or
......@@ -1399,12 +1377,10 @@ class dirstate(object):
else:
madd(fn)
elif not t.mtime_likely_equal_to(timestamp.mtime_of(st)):
ladd(fn)
elif timestamp.mtime_of(st) == lastnormaltime:
# fn may have just been marked as normal and it may have
# changed in the same second without changing its size.
# This can happen if we quickly do multiple commits.
# Force lookup, so we don't miss such a racy file change.
# There might be a change in the future if for example the
# internal clock is off, but this is a case where the issues
# the user would face would be a lot worse and there is
# nothing we can really do.
ladd(fn)
elif listclean:
cadd(fn)
......
......@@ -12,7 +12,6 @@
use crate::dirstate_tree::on_disk::DirstateV2ParseError;
use crate::{
dirstate::TruncatedTimestamp,
utils::hg_path::{HgPath, HgPathError},
PatternError,
};
......@@ -62,10 +61,6 @@ pub type HgPathCow<'a> = Cow<'a, HgPath>;
#[derive(Debug, Copy, Clone)]
pub struct StatusOptions {
/// Remember the most recent modification timeslot for status, to make
/// sure we won't miss future size-preserving file content modifications
/// that happen within the same timeslot.
pub last_normal_time: TruncatedTimestamp,
/// Whether we are on a filesystem with UNIX-like exec flags
pub check_exec: bool,
pub list_clean: bool,
......
......@@ -532,8 +532,12 @@ impl<'a, 'tree, 'on_disk> StatusCommon<'a, 'tree, 'on_disk> {
if let Some(dirstate_mtime) = entry.truncated_mtime() {
let fs_mtime = TruncatedTimestamp::for_mtime_of(fs_metadata)
.expect("OS/libc does not support mtime?");
// There might be a change in the future if for example the
// internal clock become off while process run, but this is a
// case where the issues the user would face
// would be a lot worse and there is nothing we
// can really do.
mtime_looks_clean = fs_mtime.likely_equal(dirstate_mtime)
&& !fs_mtime.likely_equal(self.options.last_normal_time)
} else {
// No mtime in the dirstate entry
mtime_looks_clean = false
......
......@@ -54,7 +54,6 @@ pub fn init_module(py: Python, package: &str) -> PyResult<PyModule> {
matcher: PyObject,
ignorefiles: PyList,
check_exec: bool,
last_normal_time: (u32, u32),
list_clean: bool,
list_ignored: bool,
list_unknown: bool,
......
......@@ -9,7 +9,6 @@
//! `hg-core` crate. From Python, this will be seen as
//! `rustext.dirstate.status`.
use crate::dirstate::item::timestamp;
use crate::{dirstate::DirstateMap, exceptions::FallbackError};
use cpython::exc::OSError;
use cpython::{
......@@ -103,13 +102,11 @@ pub fn status_wrapper(
root_dir: PyObject,
ignore_files: PyList,
check_exec: bool,
last_normal_time: (u32, u32),
list_clean: bool,
list_ignored: bool,
list_unknown: bool,
collect_traversed_dirs: bool,
) -> PyResult<PyTuple> {
let last_normal_time = timestamp(py, last_normal_time)?;
let bytes = root_dir.extract::<PyBytes>(py)?;
let root_dir = get_path_from_bytes(bytes.data(py));
......@@ -135,7 +132,6 @@ pub fn status_wrapper(
ignore_files,
StatusOptions {
check_exec,
last_normal_time,
list_clean,
list_ignored,
list_unknown,
......@@ -172,7 +168,6 @@ pub fn status_wrapper(
ignore_files,
StatusOptions {
check_exec,
last_normal_time,
list_clean,
list_ignored,
list_unknown,
......@@ -224,7 +219,6 @@ pub fn status_wrapper(
ignore_files,
StatusOptions {
check_exec,
last_normal_time,
list_clean,
list_ignored,
list_unknown,
......
......@@ -12,7 +12,7 @@ use clap::{Arg, SubCommand};
use format_bytes::format_bytes;
use hg;
use hg::config::Config;
use hg::dirstate::{has_exec_bit, TruncatedTimestamp};
use hg::dirstate::has_exec_bit;
use hg::errors::HgError;
use hg::manifest::Manifest;
use hg::matchers::AlwaysMatcher;
......@@ -194,11 +194,6 @@ pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
let mut dmap = repo.dirstate_map_mut()?;
let options = StatusOptions {
// TODO should be provided by the dirstate parsing and
// hence be stored on dmap. Using a value that assumes we aren't
// below the time resolution granularity of the FS and the
// dirstate.
last_normal_time: TruncatedTimestamp::new_truncate(0, 0),
// we're currently supporting file systems with exec flags only
// anyway
check_exec: true,
......@@ -369,7 +364,8 @@ fn unsure_is_modified(
let fs_path = hg_path_to_os_string(hg_path).expect("HgPath conversion");
let fs_metadata = vfs.symlink_metadata(&fs_path)?;
let is_symlink = fs_metadata.file_type().is_symlink();
// TODO: Also account for `FALLBACK_SYMLINK` and `FALLBACK_EXEC` from the dirstate
// TODO: Also account for `FALLBACK_SYMLINK` and `FALLBACK_EXEC` from the
// dirstate
let fs_flags = if is_symlink {
Some(b'l')
} else if has_exec_bit(&fs_metadata) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment