comparison tests/svn-safe-append.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 bdba6a2015d0
children e1e10cbb5568
comparison
equal deleted inserted replaced
36780:f3c314020beb 36781:ffa3026d4196
4 4
5 __doc__ = """Same as `echo a >> b`, but ensures a changed mtime of b. 5 __doc__ = """Same as `echo a >> b`, but ensures a changed mtime of b.
6 Without this svn will not detect workspace changes.""" 6 Without this svn will not detect workspace changes."""
7 7
8 import os 8 import os
9 import stat
9 import sys 10 import sys
10 11
11 text = sys.argv[1] 12 text = sys.argv[1]
12 fname = sys.argv[2] 13 fname = sys.argv[2]
13 14
14 f = open(fname, "ab") 15 f = open(fname, "ab")
15 try: 16 try:
16 before = os.fstat(f.fileno()).st_mtime 17 before = os.fstat(f.fileno())[stat.ST_MTIME]
17 f.write(text) 18 f.write(text)
18 f.write("\n") 19 f.write("\n")
19 finally: 20 finally:
20 f.close() 21 f.close()
21 inc = 1 22 inc = 1
22 now = os.stat(fname).st_mtime 23 now = os.stat(fname)[stat.ST_MTIME]
23 while now == before: 24 while now == before:
24 t = now + inc 25 t = now + inc
25 inc += 1 26 inc += 1
26 os.utime(fname, (t, t)) 27 os.utime(fname, (t, t))
27 now = os.stat(fname).st_mtime 28 now = os.stat(fname)[stat.ST_MTIME]
28