| 1 |
#!/usr/bin/env python3 |
| 2 |
# |
| 3 |
# mercurial - scalable distributed SCM |
| 4 |
# |
| 5 |
# Copyright 2005-2007 Olivia Mackall <[email protected]> |
| 6 |
# |
| 7 |
# This software may be used and distributed according to the terms of the |
| 8 |
# GNU General Public License version 2 or any later version. |
| 9 |
|
| 10 |
from __future__ import annotations |
| 11 |
|
| 12 |
import os |
| 13 |
import sys |
| 14 |
|
| 15 |
# Make `pip install --user ...` packages available to the official Windows |
| 16 |
# build. Most py2 packaging installs directly into the system python |
| 17 |
# environment, so no changes are necessary for other platforms. The Windows |
| 18 |
# py2 package uses py2exe, which lacks a `site` module. Hardcode it according |
| 19 |
# to the documentation. |
| 20 |
if getattr(sys, 'frozen', None) == 'console_exe': |
| 21 |
vi = sys.version_info |
| 22 |
appdata = os.environ.get('APPDATA') |
| 23 |
if appdata: |
| 24 |
sys.path.append( |
| 25 |
os.path.join( |
| 26 |
appdata, |
| 27 |
'Python', |
| 28 |
'Python%d%d' % (vi[0], vi[1]), |
| 29 |
'site-packages', |
| 30 |
) |
| 31 |
) |
| 32 |
|
| 33 |
try: |
| 34 |
from hgdemandimport import tracing |
| 35 |
except ImportError: |
| 36 |
sys.stderr.write( |
| 37 |
"abort: couldn't find mercurial libraries in [%s]\n" |
| 38 |
% ' '.join(sys.path) |
| 39 |
) |
| 40 |
sys.stderr.write("(check your install and PYTHONPATH)\n") |
| 41 |
sys.exit(-1) |
| 42 |
|
| 43 |
with tracing.log('hg script'): |
| 44 |
# enable importing on demand to reduce startup time |
| 45 |
import hgdemandimport |
| 46 |
|
| 47 |
hgdemandimport.enable() |
| 48 |
|
| 49 |
from mercurial import dispatch |
| 50 |
|
| 51 |
dispatch.run() |