[PATCH 2 of 2] util: drop statmtimesec

Laurent Charignon lcharignon at fb.com
Thu Nov 19 14:59:19 CST 2015


That looks good to me, I will let Bryan, Augie or Pierre-Yves have another look.

Thanks,

Laurent

> On Nov 19, 2015, at 12:53 PM, Matt Mackall <mpm at selenic.com> wrote:
> 
> # HG changeset patch
> # User Matt Mackall <mpm at selenic.com>
> # Date 1447960517 21600
> #      Thu Nov 19 13:15:17 2015 -0600
> # Node ID 641f529440ad6c9c5bf82455b083f69c4dc1bc39
> # Parent  94e44c088d5990336219b7d3ca7ea717dd68b823
> 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)
> 
> diff -r 94e44c088d59 -r 641f529440ad mercurial/context.py
> --- 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
> diff -r 94e44c088d59 -r 641f529440ad mercurial/dirstate.py
> --- 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.
> diff -r 94e44c088d59 -r 641f529440ad mercurial/util.py
> --- 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):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list