diffstat: make --git work properly on renames (issue6025)
ClosedPublic

Authored by navaneeth.suresh on Jan 17 2019, 7:46 AM.

Details

Summary

$ hg diff --stat --git shows only the new filename on renames.
I added the old filename also to the output to make it identical
with the output of $ git diff --stat.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
This revision was automatically updated to reflect the committed changes.

Thanks for queuing this!

yuja added a subscriber: yuja.Jan 26 2019, 12:18 AM

@@ -2808,6 +2808,10 @@

elif (line.startswith('GIT binary patch') or
      line.startswith('Binary file')):
    isbinary = True

+ elif line.startswith('rename from'):
+ filename = line.split()[-1]
+ elif line.startswith('rename to'):
+ filename += ' => %s' % line.split()[-1]

Nice.

One nit: better to not use .split() since a filename may include whitespace.

One nit: better to not use .split() since a filename may include whitespace.

Nice catch! I will send a follow-up on this.

pulkit added a subscriber: pulkit.Fri, Apr 5, 4:47 PM
pulkit added inline comments.
mercurial/patch.py
2811

This is unfortunately not working with hglib. hglib seems to be splitting data on '>' or only reading data after that.

@yuja do you have any idea what can cause that?

mercurial/patch.py
2811

@pulkit Can you add a possible test case? I would like to work on this.

By the way, Yuya has replied to this over mail and changes didn't get reflected in phab. Yuya says:

Which hglib function?

I never thought hglib would parse diffstat output. I don't think it's parsable
(i.e. BC-guaranteed) format.