[PATCH 5 of 7] patch.difffeatureopts: add a feature for whitespace diffopts

Siddharth Agarwal sid0 at fb.com
Tue Nov 25 21:54:00 CST 2014


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1416359366 28800
#      Tue Nov 18 17:09:26 2014 -0800
# Node ID f093ffdbc8f5227848dc753edc9c576abd7dbbaa
# Parent  96968af29581f3ee6ab47c0fc14b16e8a55f1751
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 --git mercurial/patch.py mercurial/patch.py
--- mercurial/patch.py
+++ mercurial/patch.py
@@ -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)
 


More information about the Mercurial-devel mailing list