Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial: which addremove --similarity default is recommended?

Tags:

mercurial

For Hg's addremove command, I'm looking for a reasonable --similarity default.

Which value works well for all kinds of files?

Which value works well for which programming language?

like image 993
mstrap Avatar asked Feb 23 '23 22:02

mstrap


1 Answers

There is no one good value. If there was, it would already be the default. Language and filetypes are largely irrelevant. What matters is the size of the file relative to the size of the changes you're making.

If you are simply moving files around without edits, 100 is the best answer. Mercurial probably won't make any mistakes guessing what adds and removes were actually renames.

If you are making small edits to large files while moving them around, then 90 might work well. Mercurial probably won't be fooled unless you've got some very similar files.

If you're making large changes to small files, you might need to go down to 50 to guess your rename. But the odds of Mercurial mistaking two different but similar files is now quite large.

(For comparison, Git uses a 50% heuristic by default for diffs and merges, but since it doesn't actually record renames in history, there's less permanent downside of guessing wrong.)

like image 167
mpm Avatar answered Feb 25 '23 12:02

mpm