[PATCH 2 of 3 STABLE] context: ability to manipulate diff feature opt-ins
yuya at tcha.org
Mon Jul 20 06:18:00 CDT 2015
On Sat, 18 Jul 2015 14:24:30 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1437254506 25200
> # Sat Jul 18 14:21:46 2015 -0700
> # Node ID b6ab3a470c0196159e8931c8c6dd4b5c4a52a4f6
> # Parent d88519184df5f9538b4f9294bee7a595d5dce6d2
> context: ability to manipulate diff feature opt-ins
> Before this patch, basectx.diff respected all diff options. Sometimes
> consumers want to opt out of certain classes of diff features.
> Change the function to call patch.difffeatureopts instead of
> diffallopts and allow the various features to be opted out of via
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -268,15 +268,23 @@ class basectx(object):
> include, exclude, default,
> auditor=r.auditor, ctx=self,
> listsubrepos=listsubrepos, badfn=badfn)
> - def diff(self, ctx2=None, match=None, **opts):
> - """Returns a diff generator for the given contexts and matcher"""
> + def diff(self, ctx2=None, match=None, allowgit=True, allowwhitespace=True,
> + allowformatchanging=True, **opts):
> + """Returns a diff generator for the given contexts and matcher.
> + The various allow* arguments control whether the diff features under
> + that category are respected. See patch.difffeatureopts.
> + """
> if ctx2 is None:
> ctx2 = self.p1()
> if ctx2 is not None:
> ctx2 = self._repo[ctx2]
> - diffopts = patch.diffopts(self._repo.ui, opts)
> + diffopts = patch.difffeatureopts(self._repo.ui, opts=opts,
> + git=allowgit,
> + whitespace=allowwhitespace,
> + formatchanging=allowformatchanging)
> return patch.diff(self._repo, ctx2, self, match=match, opts=diffopts)
I'm noob about this API, but I think patch.diff*opts() exists to pack various
diff-related options into one argument. It seems this change goes the opposite
Instead, maybe we can change templatekw.showdiffstat() to not use ctx.diff() ?
More information about the Mercurial-devel