Mercurial > hg
annotate tests/list-tree.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 |
---|---|
35217
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 from __future__ import ( |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 absolute_import, |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 print_function, |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 ) |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 import argparse |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 import os |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 ap = argparse.ArgumentParser() |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 ap.add_argument('path', nargs='+') |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 opts = ap.parse_args() |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
35380
diff
changeset
|
13 |
35217
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 def gather(): |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
15 for p in opts.path: |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 if not os.path.exists(p): |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 return |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 if os.path.isdir(p): |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 yield p + os.path.sep |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 for dirpath, dirs, files in os.walk(p): |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 for d in dirs: |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 yield os.path.join(dirpath, d) + os.path.sep |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 for f in files: |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 yield os.path.join(dirpath, f) |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 else: |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 yield p |
aa905f9cdcda
tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
27 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
35380
diff
changeset
|
28 |
35380
acff41957b34
tests: stabilize the sorted output of list-tree.py on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
35217
diff
changeset
|
29 print('\n'.join(sorted(gather(), key=lambda x: x.replace(os.path.sep, '/')))) |