dirstate: simplify the ambiguity clearing at write time
The serialization function is already doing this, so we don't need to do it
manually. We just need to propagate the right definition of "now".
Differential Revision: https://phab.mercurial-scm.org/D11501
--- a/mercurial/dirstate.py Tue Sep 28 09:32:24 2021 -0700
+++ b/mercurial/dirstate.py Wed Sep 22 14:54:42 2021 +0200
@@ -836,19 +836,17 @@
# See also the wiki page below for detail:
# https://www.mercurial-scm.org/wiki/DirstateTransactionPlan
- # emulate dropping timestamp in 'parsers.pack_dirstate'
+ # record when mtime start to be ambiguous
now = _getfsnow(self._opener)
- self._map.clearambiguoustimes(self._updatedfiles, now)
# emulate that all 'dirstate.normal' results are written out
- self._lastnormaltime = 0
self._updatedfiles.clear()
# delay writing in-memory changes out
tr.addfilegenerator(
b'dirstate',
(self._filename,),
- lambda f: self._writedirstate(tr, f),
+ lambda f: self._writedirstate(tr, f, now=now),
location=b'plain',
)
return
@@ -867,7 +865,7 @@
"""
self._plchangecallbacks[category] = callback
- def _writedirstate(self, tr, st):
+ def _writedirstate(self, tr, st, now=None):
# notify callbacks about parents change
if self._origpl is not None and self._origpl != self._pl:
for c, callback in sorted(
@@ -875,9 +873,11 @@
):
callback(self, self._origpl, self._pl)
self._origpl = None
- # use the modification time of the newly created temporary file as the
- # filesystem's notion of 'now'
- now = util.fstat(st)[stat.ST_MTIME] & _rangemask
+
+ if now is None:
+ # use the modification time of the newly created temporary file as the
+ # filesystem's notion of 'now'
+ now = util.fstat(st)[stat.ST_MTIME] & _rangemask
# enough 'delaywrite' prevents 'pack_dirstate' from dropping
# timestamp of each entries in dirstate, because of 'now > mtime'