[PATCH RFC] patch: add index line for diff output

Sean Farley sean at farley.io
Fri Jan 6 14:45:28 EST 2017


Pierre-Yves David <pierre-yves.david at ens-lyon.org> writes:

> On 12/31/2016 10:45 PM, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean at farley.io>
>> # Date 1483220517 21600
>> #      Sat Dec 31 15:41:57 2016 -0600
>> # Node ID e461e74f54822fef345ffb79bc806e32f03e93fe
>> # Parent  bd762c3d68423f7fa9e5e2b97425ed7108e0b8fc
>> patch: add index line for diff output
>
> TL;DR: let's make it a config option.

Sure, that's fine with me.

> It is usually recommended to include example of output change for such 
> patches.
>
> The change seems to from:
>
>  > diff --git a/mercurial/patch.py b/mercurial/patch.py
>  > --- a/mercurial/patch.py
>  > +++ b/mercurial/patch.py
>  > @@ -2499,10 +2499,19 @@ def trydiff(repo, revs, ctx1, ctx2, modi
>
> to
>
>  > diff --git a/mercurial/patch.py b/mercurial/patch.py
>  > index 376266343330..333637393631 100644
>  > --- a/mercurial/patch.py
>  > +++ b/mercurial/patch.py

Oh, good point, sorry I forgot.

>> This helps highlighting in third-party diff coloring (which assumes git
>> output). Is there any reason not to always output this as git does?
>
> Fun fact: we apparently have been doing git style diff wrong for over 
> 10- years (and yes, the doc seems to confirm the 'index' line is required).

Ha!

> I'm not very enthusiastic at the idea of updating our output to include 
> this. Part of that come from the fact we have been -not- including it 
> for the past 10 years so updating that output seems a bit bold. In 
> addition, Mercurial does not put the idea of "index" or filenode hash 
> forward much and from a user point of view I don't see too much value in 
> changing that.

Yeah, I would tend to agree here. Bit of a shame but not a big deal.

> So I would rather us to not touch the default output of 'hg diff --git'
>
>> The upside is that third-party tools don't need to change. The downside
>> is all the churn in the tests.
>
> Helping third party tool to work with Mercurial is definitely a large 
> win. In addition, being able to actually produce valid git diff seems 
> "useful".
>
> As we have a diff config section already have a [diff] section with tens 
> of config knob there I suggest we add one for this. From reading "git 
> diff" help there is a "full" variant of that index line. What about:
>
>    [diff]
>    extendedheader.index = [none,short,full]

Ok, that makes sense to me. There are also other headers (rename
similarity comes to mind).


More information about the Mercurial-devel mailing list