[PATCH 6 of 7] patch.difffeatureopts: add a feature for format-changing diffopts

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


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1416360123 28800
#      Tue Nov 18 17:22:03 2014 -0800
# Node ID 7451bf7e463e2932817a08d6b7114ecd363e0cfd
# Parent  f093ffdbc8f5227848dc753edc9c576abd7dbbaa
patch.difffeatureopts: add a feature for format-changing diffopts

Typically, callers that are interested in this set are also interested in the
others. We still add it as a first-class flag for convenience.

diff --git mercurial/patch.py mercurial/patch.py
--- mercurial/patch.py
+++ mercurial/patch.py
@@ -1561,17 +1561,19 @@
 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,
-                           git=True, whitespace=True)
+                           git=True, whitespace=True, formatchanging=True)
 
 diffopts = diffallopts
 
 def difffeatureopts(ui, opts=None, untrusted=False, section='diff', git=False,
-                    whitespace=False):
+                    whitespace=False, formatchanging=False):
     '''return diffopts with only opted-in features parsed
 
     Features:
     - git: git-style diffs
     - whitespace: whitespace options like ignoreblanklines and ignorews
+    - formatchanging: options that will likely break or cause correctness issues
+      with most diff parsers
     '''
     def get(key, name=None, getter=ui.configbool, forceplain=None):
         if opts:
@@ -1582,11 +1584,9 @@
             return forceplain
         return getter(section, name or key, None, untrusted=untrusted)
 
+    # core options, expected to be understood by every diff parser
     buildopts = {
-        'text': opts and opts.get('text'),
         'nodates': get('nodates'),
-        'nobinary': get('nobinary'),
-        'noprefix': get('noprefix', forceplain=False),
         'showfunc': get('show_function', 'showfunc'),
         'context': get('unified', getter=ui.config),
     }
@@ -1599,6 +1599,10 @@
                                           'ignorewsamount')
         buildopts['ignoreblanklines'] = get('ignore_blank_lines',
                                             'ignoreblanklines')
+    if formatchanging:
+        buildopts['text'] = opts and opts.get('text')
+        buildopts['nobinary'] = get('nobinary')
+        buildopts['noprefix'] = get('noprefix', forceplain=False)
 
     return mdiff.diffopts(**buildopts)
 


More information about the Mercurial-devel mailing list