Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telling Mercurial about the moved files after a major re-organization

Tags:

mercurial

We recently re-organized a very unorganized site on our server at work. This website is version controlled using Mercurial. We re-organized everything. Thousands of files. Now when I do a hg status it shows a ton of new untracked files represented by a ? and tons of missing files, which are the same files as the untracked ones, represented by a !.

How do I tell Mercurial that we moved these files? I know I can do it one-by-one, but this isn't an option given that there are thousands of them.

like image 233
Jesse Atkinson Avatar asked May 31 '12 21:05

Jesse Atkinson


People also ask

How do I revert a file in Mercurial?

To revert a file to a specific changeset, use hg revert -r CHANGESET FILENAME . This will revert the file without committing it.

How do I remove untracked files from Mercurial?

Add the Mercurial Extension called purge. It is distributed by Mercurial. It is not enabled by default, maybe to avoid accidentally removing files that you forgot to add.

What is hg status?

hg status shows the status of a repository. Files are stored in a project's working directory (which users see), and the local repository (where committed snapshots are permanently recorded). hg add tells Mercurial to track files. hg commit creates a snapshot of the changes to 1 or more files in the local repository.


2 Answers

You can use hg mv --after to signify you have already moved the file.

like image 182
Eric Y Avatar answered Oct 13 '22 01:10

Eric Y


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 
like image 37
Mark Tolonen Avatar answered Oct 13 '22 01:10

Mark Tolonen