Telling Mercurial about the moved files after a major re-organization
You can use hg mv --after
to signify you have already moved the file.
hg addremove
will detect renames after-the-fact if the files are 100% similar by default, and the similarity threshold can be overridden with -s
.
Also, if using TortoiseHg, thg guess
will bring up a dialog where you can use a slider to set the similarity and view the resulting matches between added and deleted files, then select the pairs you want to record as a rename.
Example:
C:\>hg init test
C:\>cd test
C:\test>echo >file1
C:\test>echo ONE>file1
C:\test>echo TWO>file2
C:\test>hg ci -Am init
adding file1
adding file2
C:\test>ren file1 file3
C:\test>ren file2 file4
C:\test>hg st
! file1
! file2
? file3
? file4
C:\test>hg addrem
removing file1
removing file2
adding file3
adding file4
recording removal of file1 as rename to file3 (100% similar)
recording removal of file2 as rename to file4 (100% similar)
C:\test>hg status -C # -C shows file copies.
A file3
file1 # file3 copied from file1...
A file4
file2 # file 4 copied from file2...
R file1
R file2
Use hg addremove
. You can't just move files around and expect Mercurial to know about that — if you're moving tracked files, use hg mv
.