mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
98d9269874
Summary: Create a fork of the Mercurial code that we can use to build server rpms. The hg servers will continue to exist for a few more months while we move the darkstorm and ediscovery use cases off them. In the mean time, we want to start making breaking changes to the client, so let's create a stable copy of the hg code to produce rpms for the hg servers. The fork is based off c7770c78d, the latest hg release. This copies the files as is, then adds some minor tweaks to get it to build: - Disables some lint checks that appear to be bypassed by path - sed replace eden/scm with eden/hg-server - Removed a dependency on scm/telemetry from the edenfs-client tests since scm/telemetry pulls in the original eden/scm/lib/configparser which conflicts with the hg-server conflict parser. allow-large-files Reviewed By: quark-zju Differential Revision: D27632557 fbshipit-source-id: b2f442f4ec000ea08e4d62de068750832198e1f4
93 lines
2.7 KiB
Python
93 lines
2.7 KiB
Python
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
def _fixsys():
|
|
"""Fix sys.path so core edenscm modules (edenscmnative, and 3rd party
|
|
libraries) are in sys.path
|
|
|
|
Fix sys.stdin if it's None.
|
|
"""
|
|
import os
|
|
|
|
# Do not expose those modules to edenscm.__dict__
|
|
import sys
|
|
|
|
dirname = os.path.dirname
|
|
|
|
# __file__ is "hg/edenscm/__init__.py"
|
|
# libdir is "hg/"
|
|
# Do not follow symlinks (ex. do not use "realpath"). It breaks buck build.
|
|
libdir = dirname(dirname(os.path.abspath(__file__)))
|
|
|
|
# Make "edenscmdeps.zip" available in sys.path. It includes 3rd party
|
|
# pure-Python libraries like IPython, thrift runtime, etc.
|
|
#
|
|
# Note: On Windows, the released version of hg uses python27.zip for all
|
|
# pure Python modules including edenscm and everything in edenscmdeps.zip,
|
|
# so not being able to locate edenscmdeps.zip is not fatal.
|
|
if sys.version_info[0] == 3:
|
|
name = "edenscmdeps3.zip"
|
|
else:
|
|
name = "edenscmdeps.zip"
|
|
for candidate in [libdir, os.path.join(libdir, "build")]:
|
|
depspath = os.path.join(candidate, name)
|
|
if os.path.exists(depspath) and depspath not in sys.path:
|
|
sys.path.insert(0, depspath)
|
|
|
|
# Make sure "edenscmnative" can be imported. Error early.
|
|
import edenscmnative
|
|
|
|
edenscmnative.__name__
|
|
|
|
# stdin can be None if the parent process unset the stdin file descriptor.
|
|
# Replace it early, since it may be read in layer modules, like pycompat.
|
|
if sys.stdin is None:
|
|
sys.stdin = open(os.devnull, "r")
|
|
|
|
|
|
_fixsys()
|
|
|
|
|
|
# Keep the module clean
|
|
del globals()["_fixsys"]
|
|
|
|
|
|
def run(args=None, fin=None, fout=None, ferr=None):
|
|
import sys
|
|
|
|
if args is None:
|
|
args = sys.argv
|
|
|
|
if args[1:4] == ["serve", "--cmdserver", "chgunix2"]:
|
|
# chgserver code path
|
|
|
|
# no demandimport, since chgserver wants to preimport everything.
|
|
from .mercurial import dispatch
|
|
|
|
dispatch.runchgserver()
|
|
else:
|
|
# non-chgserver code path
|
|
# - no chg in use: hgcommands::run -> HgPython::run_hg -> here
|
|
# - chg client: chgserver.runcommand -> bindings.commands.run ->
|
|
# hgcommands::run -> HgPython::run_hg -> here
|
|
|
|
from . import traceimport
|
|
|
|
traceimport.enable()
|
|
|
|
# enable demandimport after enabling traceimport
|
|
from . import hgdemandimport
|
|
|
|
hgdemandimport.enable()
|
|
|
|
# demandimport has side effect on importing dispatch.
|
|
# so 'import dispatch' happens after demandimport
|
|
from .mercurial import dispatch
|
|
|
|
dispatch.run(args, fin, fout, ferr)
|