# HG changeset patch # User Siddharth Agarwal # Date 1416359366 28800 # Node ID 41dd76b3facb27d71e7852ee74e55a6176d6b2ef # Parent 27af986a332bb1c01d16ad8a71e0072532f4bf78 patch.difffeatureopts: add a feature for whitespace diffopts These aren't exactly format-breaking features -- just ones for which patches applied to a repo will produce incorrect commits, In any case, some commands like record and annotate only care about this feature. diff -r 27af986a332b -r 41dd76b3facb mercurial/patch.py --- a/mercurial/patch.py Tue Nov 18 17:10:14 2014 -0800 +++ b/mercurial/patch.py Tue Nov 18 17:09:26 2014 -0800 @@ -1560,15 +1560,18 @@ def diffallopts(ui, opts=None, untrusted=False, section='diff'): '''return diffopts with all features supported and parsed''' - return difffeatureopts(ui, opts=opts, untrusted=untrusted, section=section) + return difffeatureopts(ui, opts=opts, untrusted=untrusted, section=section, + git=True, whitespace=True) diffopts = diffallopts -def difffeatureopts(ui, opts=None, untrusted=False, section='diff', git=False): +def difffeatureopts(ui, opts=None, untrusted=False, section='diff', git=False, + whitespace=False): '''return diffopts with only opted-in features parsed Features: - git: git-style diffs + - whitespace: whitespace options like ignoreblanklines and ignorews ''' def get(key, name=None, getter=ui.configbool, forceplain=None): if opts: @@ -1585,14 +1588,17 @@ 'nobinary': get('nobinary'), 'noprefix': get('noprefix', forceplain=False), 'showfunc': get('show_function', 'showfunc'), - 'ignorews': get('ignore_all_space', 'ignorews'), - 'ignorewsamount': get('ignore_space_change', 'ignorewsamount'), - 'ignoreblanklines': get('ignore_blank_lines', 'ignoreblanklines'), 'context': get('unified', getter=ui.config), } if git: buildopts['git'] = get('git') + if whitespace: + buildopts['ignorews'] = get('ignore_all_space', 'ignorews') + buildopts['ignorewsamount'] = get('ignore_space_change', + 'ignorewsamount') + buildopts['ignoreblanklines'] = get('ignore_blank_lines', + 'ignoreblanklines') return mdiff.diffopts(**buildopts)