I've just used eclipse to refactor a class name tracked in mercurial. Did my mercurial eclipse plugin properly track my rename or is there something i can do to help track it? How do I tell if it did track?
It does not seem I can now use the hg rename a b
command after eclipse has performed the refactor.
Eclipse on Ubuntu 18.04
Version: 2022-03 (4.23.0)
hg --version
Mercurial Distributed SCM (version 4.5.3)
I'm guessing git does not need to deal with this because of it's rename detection.
CodePudding user response:
One possibility is to use addremove with the --similarity
option.
hg addremove --similarity 80
This guesses file renames by similarity. This option takes a percentage between 0 (disabled) and 100 (files must be identical) as its parameter.
CodePudding user response:
I'm not sure what Eclipse has done, but you can definitely check if the rename was recorded correctly, and if not manually record it after the fact.
I'm assuming here that you have not yet committed the changes.
One way to check is: on the command line run hg diff -g path/to/new/file
. If the rename was recorded that should be obvious from the diff; either you will see no changes to the file or at least recognizable ones. But if it was not recorded as a rename then diff will think the entire file is completely new.
Next, if the file rename was not recorded, you can do:
hg mv -A path/to/original/filename path/to/renamed/filename
and it will then treat the file as renamed (e.g., moved). Run the diff again to confirm the effect.
A very similar case is if you refactor a file by breaking it into pieces. In that case you could use hg cp -A ...
(in place of hg mv
) to record all the derivative pieces of the original file as "copies" of it. This has the benefit that any later merges which affected the original file will propagate to all its derivatives as well, which is one of the major benefits of tracking the file history across copies/renames.