sapling/hg
Jun Wu c12e300bb8 codemod: move Python packages to edenscm
Summary:
Move top-level Python packages `mercurial`, `hgext` and `hgdemandimport` to
a new top-level package `edenscm`. This allows the Python packages provided by
the upstream Mercurial to be installed side-by-side.

To maintain compatibility, `edenscm/` gets added to `sys.path` in
`mercurial/__init__.py`.

Reviewed By: phillco, ikostia

Differential Revision: D13853115

fbshipit-source-id: b296b0673dc54c61ef6a591ebc687057ff53b22e
2019-01-28 18:35:41 -08:00

43 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 edenscm.mercurial import entrypoint
entrypoint.run(False)