views:

294

answers:

3

When committing changes to Mercurial, it can auto-detect move/copy/renames by using the command

hg addremove -similarity 100

The number after similarity indicates how similar two files need to be from 0-100% for mercurial to decide its a move, copy or rename instead of just a new file.

This is a great feature. Can TortoiseHg do this?

+7  A: 

Yes it can. If you take a look at the TortoiseHg manual you'll find section 4.12 entitled "Rename Guessing". To quote:

  1. Select one or more Unrevisioned Files
  2. Slide the similarity bar (Minimum Similarity Percentage) to the percentage match you want
  3. Press either Find Renames or Find Copies
  4. Select candidate matches and accept good matches
  5. Repeat until all unversioned files are matched

The nice thing is step 5: you can actually toggle the similarity as you go, and Tortoise changes what files are considered renames on the fly. You can get most of what you want by sliding the bar carefully to the right percentage and re-checking.

quark
Thank you so much!!! I couldn't find this anywhere (who would have thought to check the manual...) Do you happen to know if there is a way to get this to happen automatically?
Michael La Voie
As to your other question: I don't know if it can happen automatically. But Tortoise is pretty much "WYSIWYG": if there's an option for it, it's usually apparent. (The manual is thus the *second* place to look. The UI is the first. :)
quark
+3  A: 

I have my global settings (mercurial.ini) file configured with:

[defaults]
addremove = --similarity 100

If you ask me, this should be on by default.

That's a great idea, I can't see any reason not to have that set by default.
Michael La Voie
+2  A: 

setting «-s 100» defaults for addremove is awesome idea; but hgrc.5 says that [defaults] is deprecated, so I'm using these:

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

The latter is very useful for keeping track of binary data (such as cad files or drawings) that is uncompressed and distinctly segmented/layered.

d.Candela