How does Hg do file renames?

Matt Schulte matts at commtech-fastcom.com
Mon Jul 12 20:03:58 UTC 2010


  I now stand partially corrected.  It appears as if the combination of 
performing an hg rename and then an hg convert _does_ maintain the full 
list of changesets to the new repo (I think).

What does _not_ work is if you perform an hg rename on a folder and then 
try perform an hg convert on that folder.

cd ~
mkdir testrepo
cd testrepo
hg init
mkdir directory
cd directory
echo "Initial edit">file.txt
hg add file.txt
hg commit -m "Initial edit to file.txt"
echo "Second edit">>file.txt
hg commit -m "Second edit to file.txt"
cd ..
hg rename directory MyDir
hg commit -m "Renamed directory to MyDir"
cd MyDir
echo "Third edit">>file.txt
hg commit -m "Third edit to file.txt"

Some time later you decide the whole "testrepo" repository structure 
isn't the way you wanted it to be so you decide to extract the MyDir 
directory into its own repo.

cd ~
echo "include MyDir">filemap.txt
echo "rename MyDir .">>filemap.txt
hg convert --filemap filemap.txt testrepo MyDir
cd MyDir
hg up
hg log

You only have the previous two changesets: "Renamed directory to MyDir" 
& "Third edit to file.txt"

The first two changesets did not make it into this repo.

Matt Schulte
Commtech, Inc.
Voice: 316-636-1131
Fax: 316-636-1163
http://www.commtech-fastcom.com




More information about the Mercurial mailing list