Patchwork [4,of,7] patch.difffeatureopts: add a feature for diff.git

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 26, 2014, 3:53 a.m.
Message ID <96968af29581f3ee6ab4.1416974039@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6859/
State Accepted
Commit 27af986a332bb1c01d16ad8a71e0072532f4bf78
Headers show

Comments

Siddharth Agarwal - Nov. 26, 2014, 3:53 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1416359414 28800
#      Tue Nov 18 17:10:14 2014 -0800
# Node ID 96968af29581f3ee6ab47c0fc14b16e8a55f1751
# Parent  fd40c9cc3d796042efb79148c1dcbdbaf073da54
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.

Patch

diff --git mercurial/patch.py mercurial/patch.py
--- mercurial/patch.py
+++ mercurial/patch.py
@@ -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,