Patchwork [3,of,9,V2] template: directly instantiate diff options for diffstat

login
register
mail settings
Submitter Boris Feld
Date July 5, 2018, 10:26 p.m.
Message ID <e7d996be502eab72f018.1530829561@FB-lair>
Download mbox | patch
Permalink /patch/32652/
State Accepted
Headers show

Comments

Boris Feld - July 5, 2018, 10:26 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1529757031 -7200
#      Sat Jun 23 14:30:31 2018 +0200
# Node ID e7d996be502eab72f018ba756c91d0560e4a2518
# Parent  5041da43ac2ac8cd7930d2aba612bca09741d6ed
# EXP-Topic diff-cleanup
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e7d996be502e
template: directly instantiate diff options for diffstat

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -27,6 +27,7 @@  from . import (
     util,
 )
 from .utils import (
+    diffutil,
     stringutil,
 )
 
@@ -263,7 +264,8 @@  def showdiffstat(context, mapping):
     "modified files: +added/-removed lines"
     """
     ctx = context.resource(mapping, 'ctx')
-    diff = ctx.diff(opts={'noprefix': False})
+    diffopts = diffutil.diffopts(ctx._repo.ui, {'noprefix': False})
+    diff = ctx.diff(opts=diffopts)
     stats = patch.diffstatdata(util.iterlines(diff))
     maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
     return '%d: +%d/-%d' % (len(stats), adds, removes)