diff --git a/mercurial/diffutil.py b/mercurial/diffutil.py --- a/mercurial/diffutil.py +++ b/mercurial/diffutil.py @@ -30,8 +30,15 @@ - whitespace: whitespace options like ignoreblanklines and ignorews - formatchanging: options that will likely break or cause correctness issues with most diff parsers + + For the category settings (whitespace, git, formatchanging), the valid + values are True, False, or the string 'noconfig'. If the string 'noconfig' + is used, then only values in `opts` are considered, otherwise this returns + False (which is the default value for all options besides 'unified', which + does not set 'category'). ''' - def get(key, name=None, getter=ui.configbool, forceplain=None): + def get(key, name=None, getter=ui.configbool, forceplain=None, + category=None): if opts: v = opts.get(key) # diffopts flags are either None-default (which is passed @@ -45,6 +52,8 @@ return v if forceplain is not None and ui.plain(): return forceplain + if category == 'noconfig': + return False return getter(section, name or key, untrusted=untrusted) # core options, expected to be understood by every diff parser @@ -56,7 +65,7 @@ buildopts['xdiff'] = ui.configbool('experimental', 'xdiff') if git: - buildopts['git'] = get('git') + buildopts['git'] = get('git', category=git) # since this is in the experimental section, we need to call # ui.configbool directory @@ -88,18 +97,25 @@ buildopts['index'] = hlen if whitespace: - buildopts['ignorews'] = get('ignore_all_space', 'ignorews') - buildopts['ignorewsamount'] = get('ignore_space_change', + getws = lambda *args, **kwargs: get(*args, category=whitespace, + **kwargs) + + buildopts['ignorews'] = getws('ignore_all_space', 'ignorews') + buildopts['ignorewsamount'] = getws('ignore_space_change', 'ignorewsamount') - buildopts['ignoreblanklines'] = get('ignore_blank_lines', + buildopts['ignoreblanklines'] = getws('ignore_blank_lines', 'ignoreblanklines') - buildopts['ignorewseol'] = get('ignore_space_at_eol', 'ignorewseol') + buildopts['ignorewseol'] = getws('ignore_space_at_eol', 'ignorewseol') if formatchanging: + getfc = lambda *args, **kwargs: get(*args, category=formatchanging, + **kwargs) + buildopts['text'] = opts and opts.get('text') binary = None if opts is None else opts.get('binary') buildopts['nobinary'] = (not binary if binary is not None - else get('nobinary', forceplain=False)) - buildopts['noprefix'] = get('noprefix', forceplain=False) - buildopts['worddiff'] = get('word_diff', 'word-diff', forceplain=False) + else getfc('nobinary', forceplain=False)) + buildopts['noprefix'] = getfc('noprefix', forceplain=False) + buildopts['worddiff'] = getfc('word_diff', 'word-diff', + forceplain=False) return mdiff.diffopts(**pycompat.strkwargs(buildopts))