Mercurial > hg
annotate tests/mocktime.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 | 2372284d9457 |
children | 6000f5b25c9b |
rev | line source |
---|---|
34316 | 1 from __future__ import absolute_import |
2 | |
3 import os | |
4 import time | |
5 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
34316
diff
changeset
|
6 |
34316 | 7 class mocktime(object): |
8 def __init__(self, increment): | |
9 self.time = 0 | |
10 self.increment = [float(s) for s in increment.split()] | |
11 self.pos = 0 | |
12 | |
13 def __call__(self): | |
14 self.time += self.increment[self.pos % len(self.increment)] | |
15 self.pos += 1 | |
16 return self.time | |
17 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
34316
diff
changeset
|
18 |
34316 | 19 def uisetup(ui): |
20 time.time = mocktime(os.environ.get('MOCKTIME', '0.1')) |