comparison mercurial/diffutil.py @ 41573:78b270a55dc6

diff: when looking for diff configs, support a configurable prefix In a future commit, I want to make it possible to have the diff options pulled from (as an example) `commands.commit.interactive.ignorews`; previously we only supported this for customizable sections (so this would have needed a `commit-interactive` section and been named `commit-interactive.ignorews`, which felt a bit weird. Differential Revision: https://phab.mercurial-scm.org/D5833
author Kyle Lippincott <spectral@google.com>
date Thu, 31 Jan 2019 14:29:24 -0800
parents be441eb65f09
children 2372284d9457
comparison
equal deleted inserted replaced
41572:901ebc81ffb3 41573:78b270a55dc6
14 from . import ( 14 from . import (
15 mdiff, 15 mdiff,
16 pycompat, 16 pycompat,
17 ) 17 )
18 18
19 def diffallopts(ui, opts=None, untrusted=False, section='diff'): 19 def diffallopts(ui, opts=None, untrusted=False, section='diff',
20 configprefix=''):
20 '''return diffopts with all features supported and parsed''' 21 '''return diffopts with all features supported and parsed'''
21 return difffeatureopts(ui, opts=opts, untrusted=untrusted, section=section, 22 return difffeatureopts(ui, opts=opts, untrusted=untrusted, section=section,
22 git=True, whitespace=True, formatchanging=True) 23 git=True, whitespace=True, formatchanging=True,
24 configprefix=configprefix)
23 25
24 def difffeatureopts(ui, opts=None, untrusted=False, section='diff', git=False, 26 def difffeatureopts(ui, opts=None, untrusted=False, section='diff', git=False,
25 whitespace=False, formatchanging=False): 27 whitespace=False, formatchanging=False, configprefix=''):
26 '''return diffopts with only opted-in features parsed 28 '''return diffopts with only opted-in features parsed
27 29
28 Features: 30 Features:
29 - git: git-style diffs 31 - git: git-style diffs
30 - whitespace: whitespace options like ignoreblanklines and ignorews 32 - whitespace: whitespace options like ignoreblanklines and ignorews
43 # True, or False. 45 # True, or False.
44 if v or isinstance(v, bool): 46 if v or isinstance(v, bool):
45 return v 47 return v
46 if forceplain is not None and ui.plain(): 48 if forceplain is not None and ui.plain():
47 return forceplain 49 return forceplain
48 return getter(section, name or key, untrusted=untrusted) 50 return getter(section, configprefix + (name or key),
51 untrusted=untrusted)
49 52
50 # core options, expected to be understood by every diff parser 53 # core options, expected to be understood by every diff parser
51 buildopts = { 54 buildopts = {
52 'nodates': get('nodates'), 55 'nodates': get('nodates'),
53 'showfunc': get('show_function', 'showfunc'), 56 'showfunc': get('show_function', 'showfunc'),