[PATCH] diff.noprefix no longer breaks {diffstat} (issue4755)

Yuya Nishihara yuya at tcha.org
Sat Jan 14 01:28:09 EST 2017


On Fri, 13 Jan 2017 13:05:16 -0800, Gregory Szorc wrote:
> On Thu, Jan 12, 2017 at 4:10 AM, Matthieu Laneuville via Mercurial-devel <
> mercurial-devel at mercurial-scm.org> wrote:
> 
> > # HG changeset patch
> > # User Matthieu Laneuville <mlaneuville at protonmail.com>
> > # Date 1484222815 -32400
> > #      Thu Jan 12 21:06:55 2017 +0900
> > # Node ID c0030823eee2d2f320fe4b7e9d8ec90d05485980
> > # Parent  493935e0327a2dca0987a702bf06fa89b62e6a5c
> > templatekw: force noprefix=False to insure diffstat consistency (issue4755)
> >
> > The result of diffstatdata should not depend on having noprefix set or
> > not, as
> > was reported in issue 4755. Forcing noprefix to false on call makes sure
> > the
> > parser receives the diff in the correct format and returns the proper
> > result.
> >
> > Another way to fix this would have been to change the regular expressions
> > in
> > path.diffstatdata(), but that would have introduced many unecessary special
> > cases.
> >
> 
> For whoever reviews this, previous attempts at fixing this were at:
> 
> * https://www.mercurial-scm.org/pipermail/mercurial-devel/
> 2016-April/083448.html
> * https://www.mercurial-scm.org/pipermail/mercurial-devel/2015
> -December/077214.html
> 
> (The threads have interesting discussion.)
> 
> The approach in this patch seems right. I'm wondering why those of us that
> tried before didn't see this solution. It seems so... obvious.

We'd take the tri-state bool path for --no- flag option, e40343ce9c4c, per
cost/benefit ratio.

> > diff -r 493935e0327a -r c0030823eee2 mercurial/templatekw.py
> > --- a/mercurial/templatekw.py Tue Jan 10 06:59:31 2017 +0800
> > +++ b/mercurial/templatekw.py Thu Jan 12 21:06:55 2017 +0900
> > @@ -299,7 +299,7 @@
> >      """String. Statistics of changes with the following format:
> >      "modified files: +added/-removed lines"
> >      """
> > -    stats = patch.diffstatdata(util.iterlines(ctx.diff()))
> > +    stats = patch.diffstatdata(util.iterlines(ctx.diff(noprefix=False)))
> >      maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
> >      return '%s: +%s/-%s' % (len(stats), adds, removes)

Matthieu, the patch content appears to be totally corrupted because of your
mailer. Can you resend it by using patchbomb or pushgate?

https://www.mercurial-scm.org/wiki/ContributingChanges#Emailing_patches

Or maybe we can import the last attempt made by Piotr.

https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-April/083449.html


More information about the Mercurial-devel mailing list