mirror of
https://github.com/facebook/sapling.git
synced 2025-01-06 04:43:19 +03:00
92685331b1
Summary: This steals lots of code from [1] and uses dev versions of crates from [2] as well. This approach is better than calling things via `Py_Main` directly because it allows us to pre-populate the container with some data (pre-population needs to happen after `Py_Initialize` and before passing control to current Python-based hg). NB: returning `1` when the exception instance does not have a `code` attribute is an experimentally-determined decision. With `255` tests fail, so `1` just matches Python behavior. I guess we can change it anytime if we come up with exit code globbing for the tests. Reviewed By: quark-zju Differential Revision: D9482436 fbshipit-source-id: 9ca63f2358ddc1de60228c489aa9d02b4b7bc482
42 lines
1.3 KiB
Python
Executable File
42 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
#
|
|
# mercurial - scalable distributed SCM
|
|
#
|
|
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2 or any later version.
|
|
from __future__ import absolute_import
|
|
import os
|
|
import sys
|
|
|
|
libdir = "@LIBDIR@"
|
|
if libdir != "@" "LIBDIR" "@":
|
|
# Installed as a script.
|
|
if not os.path.isabs(libdir):
|
|
libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), libdir)
|
|
libdir = os.path.abspath(libdir)
|
|
sys.path.insert(0, libdir)
|
|
else:
|
|
# Not installed as a script.
|
|
# Check whether the correct interpreter is used.
|
|
try:
|
|
hgdir = os.path.dirname(os.path.realpath(__file__))
|
|
except NameError:
|
|
pass
|
|
else:
|
|
envpath = os.path.join(hgdir, "build", "env")
|
|
if os.path.exists(envpath):
|
|
with open(envpath, "r") as f:
|
|
env = dict(l.split("=", 1) for l in f.read().splitlines() if "=" in l)
|
|
# Use the right interpreter.
|
|
python = env.get("PYTHON_SYS_EXECUTABLE")
|
|
if python and python != sys.executable:
|
|
import subprocess
|
|
p = subprocess.Popen([python] + sys.argv)
|
|
sys.exit(p.wait())
|
|
|
|
from mercurial import entrypoint
|
|
|
|
entrypoint.run(False)
|