Mercurial: what addremove is the default difference recommended?

For the hg addremove command, I am looking for a reasonable one in different ways.

What value is good for all kinds of files?

What value works well for a programming language?

+4
source share
3 answers

There is nothing good. If it were, it would already be the default. The language and file types are largely irrelevant. The important thing is that the file size depends on the size of the changes you make.

If you just move files unchanged, 100 is the best answer. Mercurial will probably not make any mistakes, assuming the addition and removal are actually renamed.

If you make small changes to large files by moving them, then 90 may work well. Mercurial will probably not be fooled unless you have very similar files.

If you make big changes to small files, you may need to go down to 50 to guess your renaming. But the chances of Mercurial accepting two different but similar files are now pretty high.

(By comparison, Git uses 50% of the heuristic by default for differences and merges, but since it doesn’t actually write renames in the story, there’s a less permanent flaw of guessing is wrong.)

+4
source

You can find the appropriate value for your situation by running Mercurial with the --dry-run option. Mercurial will not do anything, but will show what it will do. You also see the similarities of each file, so you can adjust your value before performing a real action.

Example:

 hg addremove --similarity 50 --dry-run ... recording removal of ../contact_form/views.py as rename to contact_form/views.py (98% similar) 
+2
source

Note that error 3430 and note the release 2012-06-01 mention addremove :

addremove : default similarity behavior -s100

Thus, if not the "best value", -s100 (identical, simple move unchanged) is officially standard.

+2
source

All Articles