comparison mercurial/scmposix.py @ 43075:57875cf423c9

style: run a patched black on a subset of mercurial This applied black to the 20 smallest files in mercurial/: ls -S1 mercurial/*.py | tail -n20 | xargs black --skip-string-normalization Note that a few files failed to format, presumably due to a bug in my patch. The intent is to be able to compare results to D5064 with https://github.com/python/black/pull/826 applied to black. I skipped string normalization on this patch for clarity - in reality I think we'd want one pass without string normalization, followed by another to normalize strings (which is basically replacing ' with " globally.) # skip-blame mass-reformatting only Differential Revision: https://phab.mercurial-scm.org/D6342
author Augie Fackler <augie@google.com>
date Sat, 05 Oct 2019 10:29:34 -0400
parents dacfcdd8b94e
children 687b865b95ad
comparison
equal deleted inserted replaced
43074:9cc55b743713 43075:57875cf423c9
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 = 'less'
20 20
21
21 def _rcfiles(path): 22 def _rcfiles(path):
22 rcs = [os.path.join(path, 'hgrc')] 23 rcs = [os.path.join(path, 'hgrc')]
23 rcdir = os.path.join(path, 'hgrc.d') 24 rcdir = os.path.join(path, 'hgrc.d')
24 try: 25 try:
25 rcs.extend([os.path.join(rcdir, f) 26 rcs.extend(
26 for f, kind in util.listdir(rcdir) 27 [
27 if f.endswith(".rc")]) 28 os.path.join(rcdir, f)
29 for f, kind in util.listdir(rcdir)
30 if f.endswith(".rc")
31 ]
32 )
28 except OSError: 33 except OSError:
29 pass 34 pass
30 return rcs 35 return rcs
36
31 37
32 def systemrcpath(): 38 def systemrcpath():
33 path = [] 39 path = []
34 if pycompat.sysplatform == 'plan9': 40 if pycompat.sysplatform == 'plan9':
35 root = 'lib/mercurial' 41 root = 'lib/mercurial'
41 if p != '/': 47 if p != '/':
42 path.extend(_rcfiles(os.path.join(p, root))) 48 path.extend(_rcfiles(os.path.join(p, root)))
43 path.extend(_rcfiles('/' + root)) 49 path.extend(_rcfiles('/' + root))
44 return path 50 return path
45 51
52
46 def userrcpath(): 53 def userrcpath():
47 if pycompat.sysplatform == 'plan9': 54 if pycompat.sysplatform == 'plan9':
48 return [encoding.environ['home'] + '/lib/hgrc'] 55 return [encoding.environ['home'] + '/lib/hgrc']
49 elif pycompat.isdarwin: 56 elif pycompat.isdarwin:
50 return [os.path.expanduser('~/.hgrc')] 57 return [os.path.expanduser('~/.hgrc')]
51 else: 58 else:
52 confighome = encoding.environ.get('XDG_CONFIG_HOME') 59 confighome = encoding.environ.get('XDG_CONFIG_HOME')
53 if confighome is None or not os.path.isabs(confighome): 60 if confighome is None or not os.path.isabs(confighome):
54 confighome = os.path.expanduser('~/.config') 61 confighome = os.path.expanduser('~/.config')
55 62
56 return [os.path.expanduser('~/.hgrc'), 63 return [
57 os.path.join(confighome, 'hg', 'hgrc')] 64 os.path.expanduser('~/.hgrc'),
65 os.path.join(confighome, 'hg', 'hgrc'),
66 ]
67
58 68
59 def termsize(ui): 69 def termsize(ui):
60 try: 70 try:
61 import termios 71 import termios
72
62 TIOCGWINSZ = termios.TIOCGWINSZ # unavailable on IRIX (issue3449) 73 TIOCGWINSZ = termios.TIOCGWINSZ # unavailable on IRIX (issue3449)
63 except (AttributeError, ImportError): 74 except (AttributeError, ImportError):
64 return 80, 24 75 return 80, 24
65 76
66 for dev in (ui.ferr, ui.fout, ui.fin): 77 for dev in (ui.ferr, ui.fout, ui.fin):