过滤器文件从 diff 输出中移动和复制

发布于 2024-11-30 16:25:20 字数 226 浏览 0 评论 0原文

我经常查看 Mercurial 的 diff 合并,令我烦恼的是,移动的文件显示为文件删除 + 文件添加,通常位于 diff 中的两个不同位置。如果有一种方法可以用消息“文件从 .. 移动到 ..”来替换该输出,那就太好了。复制的文件也是如此。

我听说 git 有一个副本检测算法,也可以处理文件中的一些更改。

是否有一个 Mercurial 扩展或一个独立的工具,我可以将差异提供给它来检测这些文件副本?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

窗影残 2024-12-07 16:25:20

Mercurial 中的复制检测机制具有 addremove 操作

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

git(!) 扩展格式可能有帮助您可以获得所需的输出(如此处所示 ):

使用 -g/--git 选项在 git 扩展中生成差异 diff 格式

$ 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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文