# HG changeset patch # User Pierre-Yves David # Date 2021-11-23 17:13:33 # Node ID a96a5d62141ba2297923d7319a0965d3bbff487d # Parent aa8a649abe103b71990b215cd796b19dfe028fe3 largefile: use the proper "mtime boundary" logic during fixup This will prevent ambiguous cache entry to be used in racy situation. This fix flakiness in test and some real live misbehavior. Differential Revision: https://phab.mercurial-scm.org/D11800 diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -261,13 +261,10 @@ def lfdirstatestatus(lfdirstate, repo): st = wctx[lfile].lstat() mode = st.st_mode size = st.st_size - mtime = timestamp.mtime_of(st) - cache_data = (mode, size, mtime) - # We should consider using the mtime_boundary - # logic here, but largefile never actually had - # ambiguity protection before, so this confuse - # the tests and need more thinking. - lfdirstate.set_clean(lfile, cache_data) + mtime = timestamp.reliable_mtime_of(st, mtime_boundary) + if mtime is not None: + cache_data = (mode, size, mtime) + lfdirstate.set_clean(lfile, cache_data) return s diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py --- a/hgext/largefiles/reposetup.py +++ b/hgext/largefiles/reposetup.py @@ -228,13 +228,12 @@ def reposetup(ui, repo): s = wctx[lfile].lstat() mode = s.st_mode size = s.st_size - mtime = timestamp.mtime_of(s) - cache_data = (mode, size, mtime) - # We should consider using the mtime_boundary - # logic here, but largefile never actually had - # ambiguity protection before, so this confuse - # the tests and need more thinking. - lfdirstate.set_clean(lfile, cache_data) + mtime = timestamp.reliable_mtime_of( + s, mtime_boundary + ) + if mtime is not None: + cache_data = (mode, size, mtime) + lfdirstate.set_clean(lfile, cache_data) else: tocheck = unsure + modified + added + clean modified, added, clean = [], [], []