Mercurial > public > mercurial-scm > hg
comparison mercurial/posix.py @ 13986:9c374cf76b7d
move system_rcpath and user_rcpath to scmutil
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Thu, 21 Apr 2011 21:16:54 +0200 |
parents | 98ee3dd5bab4 |
children | 97ed99d1f419 |
comparison
equal
deleted
inserted
replaced
13985:26335a817dd0 | 13986:9c374cf76b7d |
---|---|
4 # | 4 # |
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from i18n import _ | 8 from i18n import _ |
9 import osutil | |
10 import os, sys, errno, stat, getpass, pwd, grp, tempfile | 9 import os, sys, errno, stat, getpass, pwd, grp, tempfile |
11 | 10 |
12 posixfile = open | 11 posixfile = open |
13 nulldev = '/dev/null' | 12 nulldev = '/dev/null' |
14 normpath = os.path.normpath | 13 normpath = os.path.normpath |
26 return True | 25 return True |
27 | 26 |
28 def nlinks(name): | 27 def nlinks(name): |
29 '''return number of hardlinks for the given file''' | 28 '''return number of hardlinks for the given file''' |
30 return os.lstat(name).st_nlink | 29 return os.lstat(name).st_nlink |
31 | |
32 def rcfiles(path): | |
33 rcs = [os.path.join(path, 'hgrc')] | |
34 rcdir = os.path.join(path, 'hgrc.d') | |
35 try: | |
36 rcs.extend([os.path.join(rcdir, f) | |
37 for f, kind in osutil.listdir(rcdir) | |
38 if f.endswith(".rc")]) | |
39 except OSError: | |
40 pass | |
41 return rcs | |
42 | |
43 def system_rcpath(): | |
44 path = [] | |
45 # old mod_python does not set sys.argv | |
46 if len(getattr(sys, 'argv', [])) > 0: | |
47 path.extend(rcfiles(os.path.dirname(sys.argv[0]) + | |
48 '/../etc/mercurial')) | |
49 path.extend(rcfiles('/etc/mercurial')) | |
50 return path | |
51 | |
52 def user_rcpath(): | |
53 return [os.path.expanduser('~/.hgrc')] | |
54 | 30 |
55 def parse_patch_output(output_line): | 31 def parse_patch_output(output_line): |
56 """parses the output produced by patch and returns the filename""" | 32 """parses the output produced by patch and returns the filename""" |
57 pf = output_line[14:] | 33 pf = output_line[14:] |
58 if os.sys.platform == 'OpenVMS': | 34 if os.sys.platform == 'OpenVMS': |