Jun Wu <quark@fb.com> [Thu, 12 Oct 2017 09:34:58 -0700] rev 34648
check-code: suggest pycompat.is(posix|windows|darwin)
Differential Revision: https://phab.mercurial-scm.org/D1037
Jun Wu <quark@fb.com> [Thu, 12 Oct 2017 23:34:34 -0700] rev 34647
codemod: use pycompat.isdarwin
This is done by:
sed -i "s/pycompat\.sysplatform == 'darwin'/pycompat.isdarwin/" **/*.py
Plus a manual change to `sslutil.py` which involves indentation change that
cannot be done by `sed`.
Differential Revision: https://phab.mercurial-scm.org/D1035
Jun Wu <quark@fb.com> [Thu, 12 Oct 2017 09:04:22 -0700] rev 34646
codemod: use pycompat.isposix
This is done by:
sed -i "s/pycompat\.osname == 'posix'/pycompat.isposix/" **/*.py
Differential Revision: https://phab.mercurial-scm.org/D1036
Jun Wu <quark@fb.com> [Thu, 12 Oct 2017 23:30:46 -0700] rev 34645
codemod: use pycompat.iswindows
This is done by:
sed -i "s/pycompat\.osname == 'nt'/pycompat.iswindows/" **/*.py
sed -i "s/pycompat\.osname != 'nt'/not pycompat.iswindows/" **/*.py
sed -i 's/pycompat.osname == "nt"/pycompat.iswindows/' **/*.py
Differential Revision: https://phab.mercurial-scm.org/D1034
Jun Wu <quark@fb.com> [Thu, 12 Oct 2017 19:20:04 -0700] rev 34644
pycompat: define operating system constants
As suggested by Ryan in D1019, it's cleaner if we use defined constants
instead of `osname == 'nt'` everywhere.
Differential Revision: https://phab.mercurial-scm.org/D1033
Jun Wu <quark@fb.com> [Wed, 11 Oct 2017 21:24:32 -0700] rev 34643
hgweb: do not import uuid immediately to avoid its side effect
With hgdemandimport disabled (chg's case), `import uuid` has an immediate
side effect calling `ctypes.util.find_library` trying to locate the
`libuuid` library. This happens at `import` time before `dispatch.run()`.
The call trace is like:
File "hg/hg", line 54, in <module>
from mercurial import (
File "hg/mercurial/dispatch.py", line 24, in <module>
from . import (
File "hg/mercurial/commands.py", line 23, in <module>
from . import (
File "hg/mercurial/help.py", line 33, in <module>
from .hgweb import (
File "hg/mercurial/hgweb/__init__.py", line 20, in <module>
from . import (
File "hg/mercurial/hgweb/hgweb_mod.py", line 14, in <module>
from .common import (
File "hg/mercurial/hgweb/common.py", line 15, in <module>
import uuid
File "/usr/lib64/python2.7/uuid.py", line 404, in <module>
lib = ctypes.CDLL(ctypes.util.find_library(libname))
The problem is, `ctypes.util.find_library` will execute
`sh -c '/sbin/ldconfig -p 2>/dev/null'` on Python <= 2.7.12. The output of
`sh` may pollute the terminal:
shell-init: error retrieving current directory: getcwd: cannot access
parent directories: No such file or directory
This patch moves `import uuid` so its side-effect can only happen after the
cwd check in `dispatch._getlocal`. Therefore the terminal won't be
polluted by importing `uuid`.
Differential Revision: https://phab.mercurial-scm.org/D1024
Jun Wu <quark@fb.com> [Wed, 11 Oct 2017 17:42:57 -0700] rev 34642
check-code: forbid platform.system()
See the previous patches for the reason.
Differential Revision: https://phab.mercurial-scm.org/D1021
Jun Wu <quark@fb.com> [Wed, 11 Oct 2017 17:42:35 -0700] rev 34641
largefiles: do not use platform.system()
See the previous patch for the reason.
Differential Revision: https://phab.mercurial-scm.org/D1020
Jun Wu <quark@fb.com> [Wed, 11 Oct 2017 17:38:20 -0700] rev 34640
logtoprocess: do not use platform.system()
See the previous patch for the reason.
Differential Revision: https://phab.mercurial-scm.org/D1019
Jun Wu <quark@fb.com> [Wed, 11 Oct 2017 17:27:21 -0700] rev 34639
selectors2: do not use platform.system()
`platform.system()` may have a side effect spawning a shell executing
`uname -p`, which may print a warning when the current directory is removed:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
This patch changes selectors2 to test the `sys.platform` string, which is a
much safer way to detect Jython.
Jython's `sys.platform` looks like this:
Jython 2.7.1 (default:
0df7adb1b397, Jun 30 2017, 19:02:43)
[OpenJDK 64-Bit Server VM (Oracle Corporation)] on java1.8.0_144
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.platform
'java1.8.0_144 ( ==linux2 for targets )'
Differential Revision: https://phab.mercurial-scm.org/D1018