14 |
14 |
15 # BSD 'more' escapes ANSI color sequences by default. This can be disabled by |
15 # BSD 'more' escapes ANSI color sequences by default. This can be disabled by |
16 # $MORE variable, but there's no compatible option with Linux 'more'. Given |
16 # $MORE variable, but there's no compatible option with Linux 'more'. Given |
17 # OS X is widely used and most modern Unix systems would have 'less', setting |
17 # OS X is widely used and most modern Unix systems would have 'less', setting |
18 # 'less' as the default seems reasonable. |
18 # 'less' as the default seems reasonable. |
19 fallbackpager = 'less' |
19 fallbackpager = b'less' |
20 |
20 |
21 |
21 |
22 def _rcfiles(path): |
22 def _rcfiles(path): |
23 rcs = [os.path.join(path, 'hgrc')] |
23 rcs = [os.path.join(path, b'hgrc')] |
24 rcdir = os.path.join(path, 'hgrc.d') |
24 rcdir = os.path.join(path, b'hgrc.d') |
25 try: |
25 try: |
26 rcs.extend( |
26 rcs.extend( |
27 [ |
27 [ |
28 os.path.join(rcdir, f) |
28 os.path.join(rcdir, f) |
29 for f, kind in util.listdir(rcdir) |
29 for f, kind in util.listdir(rcdir) |
30 if f.endswith(".rc") |
30 if f.endswith(b".rc") |
31 ] |
31 ] |
32 ) |
32 ) |
33 except OSError: |
33 except OSError: |
34 pass |
34 pass |
35 return rcs |
35 return rcs |
36 |
36 |
37 |
37 |
38 def systemrcpath(): |
38 def systemrcpath(): |
39 path = [] |
39 path = [] |
40 if pycompat.sysplatform == 'plan9': |
40 if pycompat.sysplatform == b'plan9': |
41 root = 'lib/mercurial' |
41 root = b'lib/mercurial' |
42 else: |
42 else: |
43 root = 'etc/mercurial' |
43 root = b'etc/mercurial' |
44 # old mod_python does not set sys.argv |
44 # old mod_python does not set sys.argv |
45 if len(getattr(sys, 'argv', [])) > 0: |
45 if len(getattr(sys, 'argv', [])) > 0: |
46 p = os.path.dirname(os.path.dirname(pycompat.sysargv[0])) |
46 p = os.path.dirname(os.path.dirname(pycompat.sysargv[0])) |
47 if p != '/': |
47 if p != b'/': |
48 path.extend(_rcfiles(os.path.join(p, root))) |
48 path.extend(_rcfiles(os.path.join(p, root))) |
49 path.extend(_rcfiles('/' + root)) |
49 path.extend(_rcfiles(b'/' + root)) |
50 return path |
50 return path |
51 |
51 |
52 |
52 |
53 def userrcpath(): |
53 def userrcpath(): |
54 if pycompat.sysplatform == 'plan9': |
54 if pycompat.sysplatform == b'plan9': |
55 return [encoding.environ['home'] + '/lib/hgrc'] |
55 return [encoding.environ[b'home'] + b'/lib/hgrc'] |
56 elif pycompat.isdarwin: |
56 elif pycompat.isdarwin: |
57 return [os.path.expanduser('~/.hgrc')] |
57 return [os.path.expanduser(b'~/.hgrc')] |
58 else: |
58 else: |
59 confighome = encoding.environ.get('XDG_CONFIG_HOME') |
59 confighome = encoding.environ.get(b'XDG_CONFIG_HOME') |
60 if confighome is None or not os.path.isabs(confighome): |
60 if confighome is None or not os.path.isabs(confighome): |
61 confighome = os.path.expanduser('~/.config') |
61 confighome = os.path.expanduser(b'~/.config') |
62 |
62 |
63 return [ |
63 return [ |
64 os.path.expanduser('~/.hgrc'), |
64 os.path.expanduser(b'~/.hgrc'), |
65 os.path.join(confighome, 'hg', 'hgrc'), |
65 os.path.join(confighome, b'hg', b'hgrc'), |
66 ] |
66 ] |
67 |
67 |
68 |
68 |
69 def termsize(ui): |
69 def termsize(ui): |
70 try: |
70 try: |