##// END OF EJS Templates
py3: make tests/svn-safe-append.py compatible with python 3...
Pulkit Goyal -
r39760:e1e10cbb default
parent child Browse files
Show More
@@ -1,28 +1,32 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2
2
3 from __future__ import absolute_import
3 from __future__ import absolute_import
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 stat
10 import sys
10 import sys
11
11
12 text = sys.argv[1]
12 if sys.version_info[0] >= 3:
13 fname = sys.argv[2]
13 text = os.fsencode(sys.argv[1])
14 fname = os.fsencode(sys.argv[2])
15 else:
16 text = sys.argv[1]
17 fname = sys.argv[2]
14
18
15 f = open(fname, "ab")
19 f = open(fname, "ab")
16 try:
20 try:
17 before = os.fstat(f.fileno())[stat.ST_MTIME]
21 before = os.fstat(f.fileno())[stat.ST_MTIME]
18 f.write(text)
22 f.write(text)
19 f.write("\n")
23 f.write(b"\n")
20 finally:
24 finally:
21 f.close()
25 f.close()
22 inc = 1
26 inc = 1
23 now = os.stat(fname)[stat.ST_MTIME]
27 now = os.stat(fname)[stat.ST_MTIME]
24 while now == before:
28 while now == before:
25 t = now + inc
29 t = now + inc
26 inc += 1
30 inc += 1
27 os.utime(fname, (t, t))
31 os.utime(fname, (t, t))
28 now = os.stat(fname)[stat.ST_MTIME]
32 now = os.stat(fname)[stat.ST_MTIME]
General Comments 0
You need to be logged in to leave comments. Login now