##// END OF EJS Templates
init: turn on demandimport for Python 3.6 and above...
Siddharth Agarwal -
r32424:b4810bf9 default
parent child Browse files
Show More
@@ -1,45 +1,45
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 #
2 #
3 # mercurial - scalable distributed SCM
3 # mercurial - scalable distributed SCM
4 #
4 #
5 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
5 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
6 #
6 #
7 # This software may be used and distributed according to the terms of the
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.
8 # GNU General Public License version 2 or any later version.
9
9
10 import os
10 import os
11 import sys
11 import sys
12
12
13 if os.environ.get('HGUNICODEPEDANTRY', False):
13 if os.environ.get('HGUNICODEPEDANTRY', False):
14 try:
14 try:
15 reload(sys)
15 reload(sys)
16 sys.setdefaultencoding("undefined")
16 sys.setdefaultencoding("undefined")
17 except NameError:
17 except NameError:
18 pass
18 pass
19
19
20 libdir = '@LIBDIR@'
20 libdir = '@LIBDIR@'
21
21
22 if libdir != '@' 'LIBDIR' '@':
22 if libdir != '@' 'LIBDIR' '@':
23 if not os.path.isabs(libdir):
23 if not os.path.isabs(libdir):
24 libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
24 libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
25 libdir)
25 libdir)
26 libdir = os.path.abspath(libdir)
26 libdir = os.path.abspath(libdir)
27 sys.path.insert(0, libdir)
27 sys.path.insert(0, libdir)
28
28
29 # enable importing on demand to reduce startup time
29 # enable importing on demand to reduce startup time
30 try:
30 try:
31 if sys.version_info[0] < 3:
31 if sys.version_info[0] < 3 or sys.version_info >= (3, 6):
32 from mercurial import demandimport; demandimport.enable()
32 import hgdemandimport; hgdemandimport.enable()
33 except ImportError:
33 except ImportError:
34 sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
34 sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
35 ' '.join(sys.path))
35 ' '.join(sys.path))
36 sys.stderr.write("(check your install and PYTHONPATH)\n")
36 sys.stderr.write("(check your install and PYTHONPATH)\n")
37 sys.exit(-1)
37 sys.exit(-1)
38
38
39 import mercurial.util
39 import mercurial.util
40 import mercurial.dispatch
40 import mercurial.dispatch
41
41
42 for fp in (sys.stdin, sys.stdout, sys.stderr):
42 for fp in (sys.stdin, sys.stdout, sys.stderr):
43 mercurial.util.setbinary(fp)
43 mercurial.util.setbinary(fp)
44
44
45 mercurial.dispatch.run()
45 mercurial.dispatch.run()
General Comments 0
You need to be logged in to leave comments. Login now