changeset 23432:27af986a332b

patch.difffeatureopts: add a feature for diff.git This deserves to be its own feature -- indeed, this is often the only feature several commands care about.
author Siddharth Agarwal <sid0@fb.com>
date Tue, 18 Nov 2014 17:10:14 -0800
parents 10223d2278f4
children 41dd76b3facb
files mercurial/patch.py
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Tue Nov 18 21:43:38 2014 -0800
+++ b/mercurial/patch.py	Tue Nov 18 17:10:14 2014 -0800
@@ -1564,8 +1564,12 @@
 
 diffopts = diffallopts
 
-def difffeatureopts(ui, opts=None, untrusted=False, section='diff'):
-    '''return diffopts with only opted-in features parsed'''
+def difffeatureopts(ui, opts=None, untrusted=False, section='diff', git=False):
+    '''return diffopts with only opted-in features parsed
+
+    Features:
+    - git: git-style diffs
+    '''
     def get(key, name=None, getter=ui.configbool, forceplain=None):
         if opts:
             v = opts.get(key)
@@ -1577,7 +1581,6 @@
 
     buildopts = {
         'text': opts and opts.get('text'),
-        'git': get('git'),
         'nodates': get('nodates'),
         'nobinary': get('nobinary'),
         'noprefix': get('noprefix', forceplain=False),
@@ -1588,6 +1591,9 @@
         'context': get('unified', getter=ui.config),
     }
 
+    if git:
+        buildopts['git'] = get('git')
+
     return mdiff.diffopts(**buildopts)
 
 def diff(repo, node1=None, node2=None, match=None, changes=None, opts=None,