comparison mercurial/scmposix.py @ 18690:4c6f7f0dadab

scmutil: split platform-specific bits into their own modules This parallels what's done for the util module, which imports either mercurial.posix or mercurial.windows as 'platform' and then slurps the appropriate functions into its own namespace.
author Kevin Bullock <kbullock@ringworld.org>
date Tue, 12 Feb 2013 11:36:21 -0600
parents
children 23c995ed466b
comparison
equal deleted inserted replaced
18689:12721a20ed30 18690:4c6f7f0dadab
1 import sys, os
2 import osutil
3
4 def _rcfiles(path):
5 rcs = [os.path.join(path, 'hgrc')]
6 rcdir = os.path.join(path, 'hgrc.d')
7 try:
8 rcs.extend([os.path.join(rcdir, f)
9 for f, kind in osutil.listdir(rcdir)
10 if f.endswith(".rc")])
11 except OSError:
12 pass
13 return rcs
14
15 def systemrcpath():
16 path = []
17 if sys.platform == 'plan9':
18 root = 'lib/mercurial'
19 else:
20 root = 'etc/mercurial'
21 # old mod_python does not set sys.argv
22 if len(getattr(sys, 'argv', [])) > 0:
23 p = os.path.dirname(os.path.dirname(sys.argv[0]))
24 path.extend(_rcfiles(os.path.join(p, root)))
25 path.extend(_rcfiles('/' + root))
26 return path
27
28 def userrcpath():
29 if sys.platform == 'plan9':
30 return [os.environ['home'] + '/lib/hgrc']
31 else:
32 return [os.path.expanduser('~/.hgrc')]