在Git和Mercurial中重命名:准确性和自动性 [英] Renaming in Git and Mercurial: Accuracy and automaticity

查看:197
本文介绍了在Git和Mercurial中重命名:准确性和自动性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只有几天的Git和Mercurial经验,而且我没有太多的编程经验。

在过去的几天里,我读了很多比较两者的帖子。根据我读过的和我的测试,我得到了以下结论:

Git的重命名是100%自动,但不是100%准确。它依靠算法来猜测重命名。最终用户无法改变它的决定,即使它是完全错误的。



我猜Git的方法可能适用于99%的情况,但是1%是会引起头痛。这使我很不情愿重构我的代码(同时更改类名和内容),因为如果重构过多,我将冒着丢失文件历史的风险。



Mercurial can 100%自动和100%准确,只要我总是在Visual Studio中重命名/移动我的东西并安装了VisualHG,VisualHG应该能够准确并自动地跟踪移动和重命名(目前VisualHG有一个错误 - 当我在项目之间移动文件时,文件不会重命名)。如果最终用户犯了错误,他们可以改变它的决定。

如果我没有Visual Studio,我仍然可以使用TortoiseHg的检测副本/重命名窗口,我可以设置相似性百分比,请求Mercurial自动检测重命名。如果它出错,我有机会改正它。



我的结论是对还是错?

参考:

Git和Mercurial - 比较和对比

解决方案

在这里你可以看到解释的区别,但大多数情况下你是对的。 Mercurial有 rename mv 命令可以进行真正的重命名,而Git的 mv 只是 rm add 。似乎Mercurial可以模仿Git行为并猜测你的重命名,相当不错的功能。从经验来看,Git的重命名检测算法会做出很多错误的决定 - 尤其是如果您复制文件并稍微修改两个副本 - 大部分时间都会出错。


I only have a few days of experience with Git and Mercurial, and I don't have much programming experiences.

In the past few days, I read many posts that comparing the two. Based on what I've read and my tests, I get the following conclusions:

Git's renaming is 100% automatic but not 100% accurate. It relies on algorithm to guess renames. The end users are not able to alter its decision even if it's completely wrong.

I guess Git's method might be fine for 99% of the cases, but that 1% are going to cause headaches. It makes me hesitate to refactor my code (changing class name and contents at the same time), as I'm risking losing file history if refactor too much.

Mercurial can be 100% automatic and 100% accurate, as long as I always rename/move my stuffs inside Visual Studio and have VisualHG installed, VisualHG should accurately and automatically track moving and renaming (currently VisualHG has a bug - File is not renamed when I move it between projects). And the end users can change it's decision if it makes mistakes.

If I don't have Visual Studio I can still use TortoiseHg's "Detect Copies/Renames" window, I can set a similarity percentage, ask Mercurial to automatically detect renames. If it makes mistake, I have the chance to correct it.

Are my conclusions right or wrong?

Reference:

Git and Mercurial - Compare and Contrast

解决方案

Here you can see the difference explained, but mostly you are right. Mercurial has rename and mv commands that do "real" renaming, while Git's mv just does rm and add. Also seems like Mercurial can mimic Git behavior and guess your renames, quite nice feature. From experience Git's rename detection algorithm makes wrong decisions a lot - especially if you copy a file and alter the two copies a little - most of the time it will be wrong.

这篇关于在Git和Mercurial中重命名:准确性和自动性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆