Mercurial > hg
comparison mercurial/ui.py @ 49075:7afa96d3b484
windows: disable pager when packaged with py2exe
With Windows and py3, all output that got directed to the pager was lost. It
can be worked around by the user piping to `more`, but that's easy to forget,
and can be dangerous if `hg diff` or similar incorrectly shows no changes. The
problem appears to be the new WindowsConsoleIO in py3.6[1]. We've worked around
it with PyOxidizer by setting the `Py_LegacyWindowsStdioFlag` interpreter
option, and worked around it with `hg.bat` and `exewrapper.c` by internally
setting `PYTHONLEGACYWINDOWSSTDIO=1`.
Unfortunately, py2exe doesn't appear to be able to set the interpreter option,
and somehow seems to also ignore the environment variable. The latter isn't a
good fix anyway, since setting it in the environment would affect other python
programs too. We can't install a global config for this because a config closer
to the user (e.g. from before pager was turned on by default) can override it.
[1] https://peps.python.org/pep-0528/
Differential Revision: https://phab.mercurial-scm.org/D12556
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 13 Apr 2022 15:02:01 -0400 |
parents | 642e31cb55f0 |
children | 2e726c934fcd |
comparison
equal
deleted
inserted
replaced
49074:4ba27acdea63 | 49075:7afa96d3b484 |
---|---|
1430 # We only want to paginate if the ui appears to be | 1430 # We only want to paginate if the ui appears to be |
1431 # interactive, the user didn't say HGPLAIN or | 1431 # interactive, the user didn't say HGPLAIN or |
1432 # HGPLAINEXCEPT=pager, and the user didn't specify --debug. | 1432 # HGPLAINEXCEPT=pager, and the user didn't specify --debug. |
1433 return | 1433 return |
1434 | 1434 |
1435 # py2exe doesn't appear to be able to use legacy I/O, and nothing is | |
1436 # output to the pager for paged commands. Piping to `more` in cmd.exe | |
1437 # works, but is easy to forget. Just disable pager for py2exe, but | |
1438 # leave it working for pyoxidizer and exewrapper builds. | |
1439 if pycompat.iswindows and getattr(sys, "frozen", None) == "console_exe": | |
1440 self.debug(b"pager is unavailable with py2exe packaging\n") | |
1441 return | |
1442 | |
1435 pagercmd = self.config(b'pager', b'pager', rcutil.fallbackpager) | 1443 pagercmd = self.config(b'pager', b'pager', rcutil.fallbackpager) |
1436 if not pagercmd: | 1444 if not pagercmd: |
1437 return | 1445 return |
1438 | 1446 |
1439 pagerenv = {} | 1447 pagerenv = {} |