]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/hg
torrent(1): update url in examples section
[plan9front.git] / rc / bin / hg
1 #!/bin/python
2 #
3 # mercurial - scalable distributed SCM
4 #
5 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
6 #
7 # This software may be used and distributed according to the terms of the
8 # GNU General Public License version 2, incorporated herein by reference.
9
10 # enable importing on demand to reduce startup time
11 try:
12     from mercurial import demandimport; demandimport.enable()
13 except ImportError:
14     import sys
15     sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
16                      ' '.join(sys.path))
17     sys.stderr.write("(check your install and PYTHONPATH)\n")
18     sys.exit(-1)
19
20 import sys
21 import mercurial.util
22 import mercurial.dispatch
23
24 if sys.platform == 'plan9':
25     import os
26
27     home = os.environ['home']
28     if not 'HOME' in os.environ:
29         os.environ['HOME'] = home
30
31     def p9sys_rcpath():
32         return ['/sys/lib/hgrc']
33
34     def p9usr_rcpath():
35         return [home+'/lib/hgrc']
36
37     import mercurial.posix
38     mercurial.posix.system_rcpath = p9sys_rcpath
39     mercurial.posix.user_rcpath = p9usr_rcpath
40
41 for fp in (sys.stdin, sys.stdout, sys.stderr):
42     mercurial.util.set_binary(fp)
43
44 mercurial.dispatch.run()