tests/svn-safe-append.py
changeset 36781 ffa3026d4196
parent 29195 bdba6a2015d0
child 39724 e1e10cbb5568
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