##// END OF EJS Templates
util: drop statmtimesec...
Matt Mackall -
r27016:448cbdab default
parent child Browse files
Show More
@@ -1705,7 +1705,7 b' class workingfilectx(committablefilectx)'
1705 def date(self):
1705 def date(self):
1706 t, tz = self._changectx.date()
1706 t, tz = self._changectx.date()
1707 try:
1707 try:
1708 return (util.statmtimesec(self._repo.wvfs.lstat(self._path)), tz)
1708 return (self._repo.wvfs.lstat(self._path).st_mtime, tz)
1709 except OSError as err:
1709 except OSError as err:
1710 if err.errno != errno.ENOENT:
1710 if err.errno != errno.ENOENT:
1711 raise
1711 raise
@@ -31,7 +31,7 b' def _getfsnow(vfs):'
31 '''Get "now" timestamp on filesystem'''
31 '''Get "now" timestamp on filesystem'''
32 tmpfd, tmpname = vfs.mkstemp()
32 tmpfd, tmpname = vfs.mkstemp()
33 try:
33 try:
34 return util.statmtimesec(os.fstat(tmpfd))
34 return os.fstat(tmpfd).st_mtime
35 finally:
35 finally:
36 os.close(tmpfd)
36 os.close(tmpfd)
37 vfs.unlink(tmpname)
37 vfs.unlink(tmpname)
@@ -471,7 +471,7 b' class dirstate(object):'
471 def normal(self, f):
471 def normal(self, f):
472 '''Mark a file normal and clean.'''
472 '''Mark a file normal and clean.'''
473 s = os.lstat(self._join(f))
473 s = os.lstat(self._join(f))
474 mtime = util.statmtimesec(s)
474 mtime = s.st_mtime
475 self._addpath(f, 'n', s.st_mode,
475 self._addpath(f, 'n', s.st_mode,
476 s.st_size & _rangemask, mtime & _rangemask)
476 s.st_size & _rangemask, mtime & _rangemask)
477 if f in self._copymap:
477 if f in self._copymap:
@@ -704,7 +704,7 b' class dirstate(object):'
704 def _writedirstate(self, st):
704 def _writedirstate(self, st):
705 # use the modification time of the newly created temporary file as the
705 # use the modification time of the newly created temporary file as the
706 # filesystem's notion of 'now'
706 # filesystem's notion of 'now'
707 now = util.statmtimesec(util.fstat(st)) & _rangemask
707 now = util.fstat(st).st_mtime & _rangemask
708 st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
708 st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
709 st.close()
709 st.close()
710 self._lastnormaltime = 0
710 self._lastnormaltime = 0
@@ -1078,16 +1078,15 b' class dirstate(object):'
1078 if not st and state in "nma":
1078 if not st and state in "nma":
1079 dadd(fn)
1079 dadd(fn)
1080 elif state == 'n':
1080 elif state == 'n':
1081 mtime = util.statmtimesec(st)
1082 if (size >= 0 and
1081 if (size >= 0 and
1083 ((size != st.st_size and size != st.st_size & _rangemask)
1082 ((size != st.st_size and size != st.st_size & _rangemask)
1084 or ((mode ^ st.st_mode) & 0o100 and checkexec))
1083 or ((mode ^ st.st_mode) & 0o100 and checkexec))
1085 or size == -2 # other parent
1084 or size == -2 # other parent
1086 or fn in copymap):
1085 or fn in copymap):
1087 madd(fn)
1086 madd(fn)
1088 elif time != mtime and time != mtime & _rangemask:
1087 elif time != st.st_mtime and time != st.st_mtime & _rangemask:
1089 ladd(fn)
1088 ladd(fn)
1090 elif mtime == lastnormaltime:
1089 elif st.st_mtime == lastnormaltime:
1091 # fn may have just been marked as normal and it may have
1090 # fn may have just been marked as normal and it may have
1092 # changed in the same second without changing its size.
1091 # changed in the same second without changing its size.
1093 # This can happen if we quickly do multiple commits.
1092 # This can happen if we quickly do multiple commits.
@@ -19,7 +19,6 b' import error, osutil, encoding, parsers'
19 import errno, shutil, sys, tempfile, traceback
19 import errno, shutil, sys, tempfile, traceback
20 import re as remod
20 import re as remod
21 import os, time, datetime, calendar, textwrap, signal, collections
21 import os, time, datetime, calendar, textwrap, signal, collections
22 import stat
23 import imp, socket, urllib
22 import imp, socket, urllib
24 import gc
23 import gc
25 import bz2
24 import bz2
@@ -926,20 +925,6 b' def fstat(fp):'
926 except AttributeError:
925 except AttributeError:
927 return os.stat(fp.name)
926 return os.stat(fp.name)
928
927
929 def statmtimesec(st):
930 """Get mtime as integer of seconds
931
932 'int(st.st_mtime)' cannot be used because st.st_mtime is computed as
933 'sec + 1e-9 * nsec' and double-precision floating-point type is too narrow
934 to represent nanoseconds. If 'nsec' is close to 1 sec, 'int(st.st_mtime)'
935 can be 'sec + 1'. (issue4836)
936 """
937 try:
938 return st[stat.ST_MTIME]
939 except (TypeError, IndexError):
940 # osutil.stat doesn't allow index access and its st_mtime is int
941 return st.st_mtime
942
943 # File system features
928 # File system features
944
929
945 def checkcase(path):
930 def checkcase(path):
General Comments 0
You need to be logged in to leave comments. Login now