2018-09-13 02:33:35 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2018-08-17 20:40:01 +03:00
|
|
|
# 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
|
|
|
|
|
2019-01-30 03:25:33 +03:00
|
|
|
|
2018-08-30 14:40:35 +03:00
|
|
|
def run(binaryexecution):
|
2018-08-17 20:40:01 +03:00
|
|
|
# entrypoint is in mercurial/ dir, while we want 'from mercurial import ...',
|
|
|
|
# 'from hgext import ...' and 'from hgdemandimport import ...' to work
|
|
|
|
# so we are adding their parent directory to be the first item of sys.path
|
2018-09-13 00:35:13 +03:00
|
|
|
# Do not follow symlinks (ex. do not use "realpath"). It breaks buck build.
|
|
|
|
filedir = os.path.dirname(os.path.abspath(__file__))
|
2019-01-30 03:25:33 +03:00
|
|
|
libdir = os.path.dirname(os.path.dirname(filedir))
|
2018-08-17 20:40:01 +03:00
|
|
|
if sys.path[0] != libdir:
|
|
|
|
sys.path.insert(0, libdir)
|
|
|
|
|
2019-01-21 16:45:48 +03:00
|
|
|
for element in list(sys.path):
|
|
|
|
if os.path.realpath(filedir) == os.path.realpath(element):
|
|
|
|
# the directory of entrypoint.py is mercurial/
|
|
|
|
# and it should not be present in sys.path, as we use absolute_import
|
|
|
|
sys.path.remove(element)
|
2018-08-17 20:40:01 +03:00
|
|
|
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm import hgdemandimport
|
2018-10-13 00:47:54 +03:00
|
|
|
|
|
|
|
hgdemandimport.tryenableembedded()
|
|
|
|
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import encoding
|
2018-08-17 20:40:01 +03:00
|
|
|
|
|
|
|
if encoding.environ.get("HGUNICODEPEDANTRY", False):
|
|
|
|
try:
|
|
|
|
reload(sys)
|
|
|
|
sys.setdefaultencoding("undefined")
|
|
|
|
except NameError:
|
|
|
|
pass
|
|
|
|
|
2018-12-20 02:54:00 +03:00
|
|
|
# Make available various deps that are either not new enough on the system
|
|
|
|
# or not provided by the system. These include a newer version of IPython
|
|
|
|
# for `hg dbsh` and the thrift runtime for the eden extension
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import thirdparty
|
2018-12-20 02:54:00 +03:00
|
|
|
|
|
|
|
ipypath = os.path.join(os.path.dirname(thirdparty.__file__), "IPython.zip")
|
|
|
|
if ipypath not in sys.path and os.path.exists(ipypath):
|
|
|
|
sys.path.insert(0, ipypath)
|
|
|
|
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import executionmodel
|
2018-08-17 20:40:14 +03:00
|
|
|
|
2018-10-23 18:25:50 +03:00
|
|
|
executionmodel.setbinaryexecution(binaryexecution)
|
2018-08-17 20:40:14 +03:00
|
|
|
|
2018-08-17 20:40:01 +03:00
|
|
|
if (
|
2019-02-09 01:51:20 +03:00
|
|
|
sys.argv[1:5] == ["serve", "--cmdserver", "chgunix2", "--address"]
|
2018-08-17 20:40:01 +03:00
|
|
|
and sys.argv[6:8] == ["--daemon-postexec", "chdir:/"]
|
|
|
|
and "CHGINTERNALMARK" in encoding.environ
|
|
|
|
):
|
|
|
|
# Shortcut path for chg server
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import dispatch
|
2018-08-17 20:40:01 +03:00
|
|
|
|
|
|
|
dispatch.runchgserver()
|
|
|
|
else:
|
|
|
|
# Non-chg path
|
|
|
|
try:
|
|
|
|
if sys.version_info[0] < 3 or sys.version_info >= (3, 6):
|
|
|
|
hgdemandimport.enable()
|
|
|
|
except ImportError:
|
|
|
|
sys.stderr.write(
|
|
|
|
"abort: couldn't find mercurial libraries in [%s]\n"
|
|
|
|
% " ".join(sys.path)
|
|
|
|
)
|
|
|
|
sys.stderr.write("(check your install and PYTHONPATH)\n")
|
|
|
|
sys.exit(-1)
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import dispatch
|
2018-08-17 20:40:01 +03:00
|
|
|
|
|
|
|
dispatch.run()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2018-08-30 14:40:35 +03:00
|
|
|
run(True)
|