Mercurial > hg
comparison mercurial/dirstate.py @ 36781:ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
The latter is floating point by default, and we've been doing
os.stat_float_times(False). Unfortunately, os.stat_float_times was
removed between Python 3.7.0a1 and 3.7.0b2, so we have to stop using
it.
Differential Revision: https://phab.mercurial-scm.org/D2696
author | Augie Fackler <augie@google.com> |
---|---|
date | Mon, 05 Mar 2018 12:30:20 -0500 |
parents | 0297f9c4caee |
children | d5d42c170f4d |
comparison
equal
deleted
inserted
replaced
36780:f3c314020beb | 36781:ffa3026d4196 |
---|---|
47 | 47 |
48 def _getfsnow(vfs): | 48 def _getfsnow(vfs): |
49 '''Get "now" timestamp on filesystem''' | 49 '''Get "now" timestamp on filesystem''' |
50 tmpfd, tmpname = vfs.mkstemp() | 50 tmpfd, tmpname = vfs.mkstemp() |
51 try: | 51 try: |
52 return os.fstat(tmpfd).st_mtime | 52 return os.fstat(tmpfd)[stat.ST_MTIME] |
53 finally: | 53 finally: |
54 os.close(tmpfd) | 54 os.close(tmpfd) |
55 vfs.unlink(tmpname) | 55 vfs.unlink(tmpname) |
56 | 56 |
57 class dirstate(object): | 57 class dirstate(object): |
385 self._map.addfile(f, oldstate, state, mode, size, mtime) | 385 self._map.addfile(f, oldstate, state, mode, size, mtime) |
386 | 386 |
387 def normal(self, f): | 387 def normal(self, f): |
388 '''Mark a file normal and clean.''' | 388 '''Mark a file normal and clean.''' |
389 s = os.lstat(self._join(f)) | 389 s = os.lstat(self._join(f)) |
390 mtime = s.st_mtime | 390 mtime = s[stat.ST_MTIME] |
391 self._addpath(f, 'n', s.st_mode, | 391 self._addpath(f, 'n', s.st_mode, |
392 s.st_size & _rangemask, mtime & _rangemask) | 392 s.st_size & _rangemask, mtime & _rangemask) |
393 self._map.copymap.pop(f, None) | 393 self._map.copymap.pop(f, None) |
394 if f in self._map.nonnormalset: | 394 if f in self._map.nonnormalset: |
395 self._map.nonnormalset.remove(f) | 395 self._map.nonnormalset.remove(f) |
624 for c, callback in sorted(self._plchangecallbacks.iteritems()): | 624 for c, callback in sorted(self._plchangecallbacks.iteritems()): |
625 callback(self, self._origpl, self._pl) | 625 callback(self, self._origpl, self._pl) |
626 self._origpl = None | 626 self._origpl = None |
627 # use the modification time of the newly created temporary file as the | 627 # use the modification time of the newly created temporary file as the |
628 # filesystem's notion of 'now' | 628 # filesystem's notion of 'now' |
629 now = util.fstat(st).st_mtime & _rangemask | 629 now = util.fstat(st)[stat.ST_MTIME] & _rangemask |
630 | 630 |
631 # enough 'delaywrite' prevents 'pack_dirstate' from dropping | 631 # enough 'delaywrite' prevents 'pack_dirstate' from dropping |
632 # timestamp of each entries in dirstate, because of 'now > mtime' | 632 # timestamp of each entries in dirstate, because of 'now > mtime' |
633 delaywrite = self._ui.configint('debug', 'dirstate.delaywrite') | 633 delaywrite = self._ui.configint('debug', 'dirstate.delaywrite') |
634 if delaywrite > 0: | 634 if delaywrite > 0: |
1066 ((size != st.st_size and size != st.st_size & _rangemask) | 1066 ((size != st.st_size and size != st.st_size & _rangemask) |
1067 or ((mode ^ st.st_mode) & 0o100 and checkexec)) | 1067 or ((mode ^ st.st_mode) & 0o100 and checkexec)) |
1068 or size == -2 # other parent | 1068 or size == -2 # other parent |
1069 or fn in copymap): | 1069 or fn in copymap): |
1070 madd(fn) | 1070 madd(fn) |
1071 elif time != st.st_mtime and time != st.st_mtime & _rangemask: | 1071 elif (time != st[stat.ST_MTIME] |
1072 and time != st[stat.ST_MTIME] & _rangemask): | |
1072 ladd(fn) | 1073 ladd(fn) |
1073 elif st.st_mtime == lastnormaltime: | 1074 elif st[stat.ST_MTIME] == lastnormaltime: |
1074 # fn may have just been marked as normal and it may have | 1075 # fn may have just been marked as normal and it may have |
1075 # changed in the same second without changing its size. | 1076 # changed in the same second without changing its size. |
1076 # This can happen if we quickly do multiple commits. | 1077 # This can happen if we quickly do multiple commits. |
1077 # Force lookup, so we don't miss such a racy file change. | 1078 # Force lookup, so we don't miss such a racy file change. |
1078 ladd(fn) | 1079 ladd(fn) |