##// END OF EJS Templates
hg: move unreachable code to where it could be reached
Jason R. Coombs -
r51427:057639af default
parent child Browse files
Show More
@@ -1,59 +1,59 b''
1 #!/usr/bin/env python3
1 #!/usr/bin/env python3
2 #
2 #
3 # mercurial - scalable distributed SCM
3 # mercurial - scalable distributed SCM
4 #
4 #
5 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
5 # Copyright 2005-2007 Olivia Mackall <olivia@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 libdir = '@LIBDIR@'
13 libdir = '@LIBDIR@'
14
14
15 if libdir != '@' 'LIBDIR' '@':
15 if libdir != '@' 'LIBDIR' '@':
16 if not os.path.isabs(libdir):
16 if not os.path.isabs(libdir):
17 libdir = os.path.join(
17 libdir = os.path.join(
18 os.path.dirname(os.path.realpath(__file__)), libdir
18 os.path.dirname(os.path.realpath(__file__)), libdir
19 )
19 )
20 libdir = os.path.abspath(libdir)
20 libdir = os.path.abspath(libdir)
21 sys.path.insert(0, libdir)
21 sys.path.insert(0, libdir)
22
22
23 # Make `pip install --user ...` packages available to the official Windows
23 # Make `pip install --user ...` packages available to the official Windows
24 # build. Most py2 packaging installs directly into the system python
24 # build. Most py2 packaging installs directly into the system python
25 # environment, so no changes are necessary for other platforms. The Windows
25 # environment, so no changes are necessary for other platforms. The Windows
26 # py2 package uses py2exe, which lacks a `site` module. Hardcode it according
26 # py2 package uses py2exe, which lacks a `site` module. Hardcode it according
27 # to the documentation.
27 # to the documentation.
28 if getattr(sys, 'frozen', None) == 'console_exe':
28 if getattr(sys, 'frozen', None) == 'console_exe':
29 vi = sys.version_info
29 vi = sys.version_info
30 appdata = os.environ.get('APPDATA')
30 appdata = os.environ.get('APPDATA')
31 if appdata:
31 if appdata:
32 sys.path.append(
32 sys.path.append(
33 os.path.join(
33 os.path.join(
34 appdata,
34 appdata,
35 'Python',
35 'Python',
36 'Python%d%d' % (vi[0], vi[1]),
36 'Python%d%d' % (vi[0], vi[1]),
37 'site-packages',
37 'site-packages',
38 )
38 )
39 )
39 )
40
40
41 from hgdemandimport import tracing
41 try:
42 from hgdemandimport import tracing
43 except ImportError:
44 sys.stderr.write(
45 "abort: couldn't find mercurial libraries in [%s]\n"
46 % ' '.join(sys.path)
47 )
48 sys.stderr.write("(check your install and PYTHONPATH)\n")
49 sys.exit(-1)
42
50
43 with tracing.log('hg script'):
51 with tracing.log('hg script'):
44 # enable importing on demand to reduce startup time
52 # enable importing on demand to reduce startup time
45 try:
53 import hgdemandimport
46 import hgdemandimport
47
54
48 hgdemandimport.enable()
55 hgdemandimport.enable()
49 except ImportError:
50 sys.stderr.write(
51 "abort: couldn't find mercurial libraries in [%s]\n"
52 % ' '.join(sys.path)
53 )
54 sys.stderr.write("(check your install and PYTHONPATH)\n")
55 sys.exit(-1)
56
56
57 from mercurial import dispatch
57 from mercurial import dispatch
58
58
59 dispatch.run()
59 dispatch.run()
General Comments 0
You need to be logged in to leave comments. Login now