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

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 22, 2014, 1 a.m.
Message ID <6aa17cf4615cef0e44c9.1416618008@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6827/
State Superseded
Commit 60300a4c0ae52829931eaf24e30fac016d5ee9f8
Headers show

Comments

Siddharth Agarwal - Nov. 22, 2014, 1 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1416360123 28800
#      Tue Nov 18 17:22:03 2014 -0800
# Node ID 6aa17cf4615cef0e44c99d73864db1aa244ea580
# Parent  ad1f8562f7be97be977b013071ce0bdb1541649c
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.

Patch

diff --git mercurial/patch.py mercurial/patch.py
--- mercurial/patch.py
+++ mercurial/patch.py
@@ -1560,12 +1560,12 @@ 
 
 def diffallopts(ui, opts=None, untrusted=False, section='diff'):
     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):
     def get(key, name=None, getter=ui.configbool, forceplain=None):
         if opts:
             v = opts.get(key)
@@ -1575,11 +1575,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),
     }
@@ -1592,6 +1590,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)