开发者

filter file moves and copies from diff output

开发者 https://www.devze.com 2023-03-29 15:36 出处:网络
I look a lot at diff merges from mercurial, and it annoys me that moved files are shown as file deletion + file addition, often at two different places in the diff. It would be great开发者_如何学运维

I look a lot at diff merges from mercurial, and it annoys me that moved files are shown as file deletion + file addition, often at two different places in the diff. It would be great开发者_如何学运维 if there was a way to replace that output by the message "file moved from .. to ..". The same goes for copied files.

I have heard that git has a copy detection algorithm that can also handle some changes in the files.

Is there a mercurial extension or a standalone tool I can feed my diff to that detects these file copies as well?


The copy detection mechanism in Mercurial has a "similarity" parameter for addremove operation:

[alias]
addremove = addremove --similarity 100
adrs = addremove --similarity 0.01

The git(!) extended format might help you to get the desired output (as illustrated here):

Use the -g/--git option to generate diffs in the git extended diff format.

$ mv c b

sjl at ecgtheow in ~/Desktop/test on default! 
$ hg addremove --similarity 100
adding b
removing c
recording removal of c as rename to b (100% similar)

sjl at ecgtheow in ~/Desktop/test on default! 
$ hg diff
diff --git a/c b/b
rename from c
rename to b
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号