Mercurial > hg
changeset 27016:448cbdab5883
util: drop statmtimesec
We've globablly forced stat to return integer times which agrees with
our extension code, so this is no longer needed.
This speeds up status on mozilla-central substantially:
$ hg perfstatus
! wall 0.190179 comb 0.180000 user 0.120000 sys 0.060000 (best of 53)
$ hg perfstatus
! wall 0.275729 comb 0.270000 user 0.210000 sys 0.060000 (best of 36)
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 19 Nov 2015 13:15:17 -0600 |
parents | 341cb90ffd18 |
children | cdc3e437b481 |
files | mercurial/context.py mercurial/dirstate.py mercurial/util.py |
diffstat | 3 files changed, 6 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Thu Nov 19 13:21:24 2015 -0600 +++ b/mercurial/context.py Thu Nov 19 13:15:17 2015 -0600 @@ -1705,7 +1705,7 @@ def date(self): t, tz = self._changectx.date() try: - return (util.statmtimesec(self._repo.wvfs.lstat(self._path)), tz) + return (self._repo.wvfs.lstat(self._path).st_mtime, tz) except OSError as err: if err.errno != errno.ENOENT: raise
--- a/mercurial/dirstate.py Thu Nov 19 13:21:24 2015 -0600 +++ b/mercurial/dirstate.py Thu Nov 19 13:15:17 2015 -0600 @@ -31,7 +31,7 @@ '''Get "now" timestamp on filesystem''' tmpfd, tmpname = vfs.mkstemp() try: - return util.statmtimesec(os.fstat(tmpfd)) + return os.fstat(tmpfd).st_mtime finally: os.close(tmpfd) vfs.unlink(tmpname) @@ -471,7 +471,7 @@ def normal(self, f): '''Mark a file normal and clean.''' s = os.lstat(self._join(f)) - mtime = util.statmtimesec(s) + mtime = s.st_mtime self._addpath(f, 'n', s.st_mode, s.st_size & _rangemask, mtime & _rangemask) if f in self._copymap: @@ -704,7 +704,7 @@ def _writedirstate(self, st): # use the modification time of the newly created temporary file as the # filesystem's notion of 'now' - now = util.statmtimesec(util.fstat(st)) & _rangemask + now = util.fstat(st).st_mtime & _rangemask st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now)) st.close() self._lastnormaltime = 0 @@ -1078,16 +1078,15 @@ if not st and state in "nma": dadd(fn) elif state == 'n': - mtime = util.statmtimesec(st) if (size >= 0 and ((size != st.st_size and size != st.st_size & _rangemask) or ((mode ^ st.st_mode) & 0o100 and checkexec)) or size == -2 # other parent or fn in copymap): madd(fn) - elif time != mtime and time != mtime & _rangemask: + elif time != st.st_mtime and time != st.st_mtime & _rangemask: ladd(fn) - elif mtime == lastnormaltime: + elif st.st_mtime == 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.
--- a/mercurial/util.py Thu Nov 19 13:21:24 2015 -0600 +++ b/mercurial/util.py Thu Nov 19 13:15:17 2015 -0600 @@ -19,7 +19,6 @@ import errno, shutil, sys, tempfile, traceback import re as remod import os, time, datetime, calendar, textwrap, signal, collections -import stat import imp, socket, urllib import gc import bz2 @@ -926,20 +925,6 @@ except AttributeError: return os.stat(fp.name) -def statmtimesec(st): - """Get mtime as integer of seconds - - 'int(st.st_mtime)' cannot be used because st.st_mtime is computed as - 'sec + 1e-9 * nsec' and double-precision floating-point type is too narrow - to represent nanoseconds. If 'nsec' is close to 1 sec, 'int(st.st_mtime)' - can be 'sec + 1'. (issue4836) - """ - try: - return st[stat.ST_MTIME] - except (TypeError, IndexError): - # osutil.stat doesn't allow index access and its st_mtime is int - return st.st_mtime - # File system features def checkcase(path):