Renaming in Git and Mercurial: Accuracy and automaticity
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%开发者_JAVA技巧 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.
I don't think that Mercurial's ability to track file renames is nearly so perfect as you seem to think it might be. I don't have much experience with Git, but I do have a good bit with Mercurial, and renaming files seems to work OK in some contexts (hg view
understands them), so long as you haven't done anything too "interesting" (which seems to happen somewhat frequently).
And Git, by reputation at least, is supposed to let you make low-level changes to history if you need to.
精彩评论