Mercurial > hg
annotate tests/svn-safe-append.py @ 44261:04a3ae7aba14
chg: force-set LC_CTYPE on server start to actual value from the environment
Python 3.7+ will "coerce" the LC_CTYPE variable in many instances, and this can
cause issues with chg being able to start up. D7550 attempted to fix this, but a
combination of a misreading of the way that python3.7 does the coercion and an
untested state (LC_CTYPE being set to an invalid value) meant that this was
still not quite working.
This change will cause differences between chg and hg: hg will have the LC_CTYPE
environment variable coerced, while chg will not. This is unlikely to cause any
detectable behavior differences in what Mercurial itself outputs, but it does
have two known effects:
- When using hg, the coerced LC_CTYPE will be passed to subprocesses, even
non-python ones. Using chg will remove the coercion, and this will not
happen. This is arguably more correct behavior on chg's part.
- On macOS, if you set your region to Brazil but your language to English,
this isn't representable in locale strings, so macOS sets LC_CTYPE=UTF-8. If
this value is passed along when ssh'ing to a non-macOS machine, some
functions (such as locale.setlocale()) may raise an exception due to an
unsupported locale setting. This is most easily encountered when doing an
interactive commit/split/etc. when using ui.interface=curses.
Differential Revision: https://phab.mercurial-scm.org/D8039
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Wed, 29 Jan 2020 13:39:50 -0800 |
parents | e1e10cbb5568 |
children | c102b704edb5 |
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 |
39724
e1e10cbb5568
py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36781
diff
changeset
|
12 if sys.version_info[0] >= 3: |
e1e10cbb5568
py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36781
diff
changeset
|
13 text = os.fsencode(sys.argv[1]) |
e1e10cbb5568
py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36781
diff
changeset
|
14 fname = os.fsencode(sys.argv[2]) |
e1e10cbb5568
py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36781
diff
changeset
|
15 else: |
e1e10cbb5568
py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36781
diff
changeset
|
16 text = sys.argv[1] |
e1e10cbb5568
py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36781
diff
changeset
|
17 fname = sys.argv[2] |
6439
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
18 |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
19 f = open(fname, "ab") |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
20 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
|
21 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
|
22 f.write(text) |
39724
e1e10cbb5568
py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36781
diff
changeset
|
23 f.write(b"\n") |
6439
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
24 finally: |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
25 f.close() |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
26 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
|
27 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
|
28 while now == before: |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
29 t = now + inc |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
30 inc += 1 |
c1b47c0fd2b6
convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
31 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
|
32 now = os.stat(fname)[stat.ST_MTIME] |