comparison tests/svn-safe-append.py @ 6439:c1b47c0fd2b6

convert: fix test-convert-svn-* problems with mtime not changing The `svn commit` command does not detect changed files unless their mtime has changed. A quick succession of, for instance, `svn co ...; echo x >> y; svn ci` can thus lead to the change to y being ignored. Edited by pmezard to write in binary mode.
author Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
date Tue, 01 Apr 2008 09:17:11 +0200
parents
children bdba6a2015d0
comparison
equal deleted inserted replaced
6438:a60b711c7ac4 6439:c1b47c0fd2b6
1 #!/usr/bin/env python
2
3 __doc__ = """Same as `echo a >> b`, but ensures a changed mtime of b.
4 Without this svn will not detect workspace changes."""
5
6 import sys, os
7
8 text = sys.argv[1]
9 fname = sys.argv[2]
10
11 f = open(fname, "ab")
12 try:
13 before = os.fstat(f.fileno()).st_mtime
14 f.write(text)
15 f.write("\n")
16 finally:
17 f.close()
18 inc = 1
19 now = os.stat(fname).st_mtime
20 while now == before:
21 t = now + inc
22 inc += 1
23 os.utime(fname, (t, t))
24 now = os.stat(fname).st_mtime
25