Patchwork [6,of,8,git-diff] patch: add similarity config knob in experimental section

login
register
mail settings
Submitter Sean Farley
Date Jan. 9, 2017, 7:49 p.m.
Message ID <f755adaeac8d325dbb99.1483991379@1.0.0.127.in-addr.arpa>
Download mbox | patch
Permalink /patch/18151/
State Accepted
Headers show

Comments

Sean Farley - Jan. 9, 2017, 7:49 p.m.
# HG changeset patch
# User Sean Farley <sean@farley.io>
# Date 1483987904 28800
#      Mon Jan 09 10:51:44 2017 -0800
# Node ID f755adaeac8d325dbb99f759929e88a342368ed2
# Parent  8561e240f25e851476abde452b850fc09a7fdf06
patch: add similarity config knob in experimental section

This config knob will control whether or not to show the similarity
calculation in the diff output:

  diff --git a/README.md b/foo.md
  similarity index 88%
  rename from README.md
  rename to foo.md
  --- a/README.md
  +++ b/foo.md

Patch

diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
--- a/mercurial/mdiff.py
+++ b/mercurial/mdiff.py
@@ -55,10 +55,11 @@  class diffopts(object):
         'index': 0,
         'ignorews': False,
         'ignorewsamount': False,
         'ignoreblanklines': False,
         'upgrade': False,
+        'showsimilarity': False,
         }
 
     def __init__(self, **opts):
         for k in self.defaults.keys():
             v = opts.get(k)
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2167,10 +2167,15 @@  def difffeatureopts(ui, opts=None, untru
     }
 
     if git:
         buildopts['git'] = get('git')
 
+        # since this is in the experimental section, we need to call
+        # ui.configbool directory
+        buildopts['showsimilarity'] = ui.configbool('experimental',
+                                                    'extendedheader.similarity')
+
         # need to inspect the ui object instead of using get() since we want to
         # test for an int
         hconf = ui.config('experimental', 'extendedheader.index')
         if hconf is not None:
             hlen = None