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