Mercurial > hg
annotate tests/svn-safe-append.py @ 37785:b4d85bc122bd
wireproto: rename wireproto to wireprotov1server (API)
We have wireprotov2server, wireprotov1peer, and wireprotov2peer.
wireproto only contains server functionality. So it makes sense to
rename it to wireprotov1server so the naming aligns with everything
else.
Differential Revision: https://phab.mercurial-scm.org/D3400
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 16 Apr 2018 22:21:54 -0700 |
parents | ffa3026d4196 |
children | e1e10cbb5568 |
rev | line source |
---|---|
6439
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
2 |
29195
bdba6a2015d0
py3: make tests/svn-safe-append.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
6439
diff
changeset
|
3 from __future__ import absolute_import |
bdba6a2015d0
py3: make tests/svn-safe-append.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
6439
diff
changeset
|
4 |
6439
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
5 __doc__ = """Same as `echo a >> b`, but ensures a changed mtime of b. |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
6 Without this svn will not detect workspace changes.""" |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
7 |
29195
bdba6a2015d0
py3: make tests/svn-safe-append.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
6439
diff
changeset
|
8 import os |
36781
ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents:
29195
diff
changeset
|
9 import stat |
29195
bdba6a2015d0
py3: make tests/svn-safe-append.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
6439
diff
changeset
|
10 import sys |
6439
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
11 |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
12 text = sys.argv[1] |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
13 fname = sys.argv[2] |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
14 |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
15 f = open(fname, "ab") |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
16 try: |
36781
ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents:
29195
diff
changeset
|
17 before = os.fstat(f.fileno())[stat.ST_MTIME] |
6439
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
18 f.write(text) |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
19 f.write("\n") |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
20 finally: |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
21 f.close() |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
22 inc = 1 |
36781
ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents:
29195
diff
changeset
|
23 now = os.stat(fname)[stat.ST_MTIME] |
6439
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
24 while now == before: |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
25 t = now + inc |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
26 inc += 1 |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
27 os.utime(fname, (t, t)) |
36781
ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents:
29195
diff
changeset
|
28 now = os.stat(fname)[stat.ST_MTIME] |