How does Hg do file renames?
Daniel Carrera
dcarrera at gmail.com
Sun Jul 11 22:28:58 UTC 2010
Hello,
My understanding is that Mercurial does not handle file renames
explicitly. So what exactly happens when you type "hg mv"? Poking
around the Hg store, this is what seems to happen:
1) Hg seems to keep track of file copies.
2) "hg mv foo bar" seems to be equivalent to "hg copy foo bar && hg rm foo".
Internally, Hg creates a new filelog for "bar" and that filelog says
"copy of foo". Am I right so far? So, renames are not tracked
explicitly, which is why some operations can fail:
~ % mkdir repo1
~ % cd repo1
~/repo1 % hg init
~/repo1 % echo "Hello" > file
~/repo1 % hg add file
~/repo1 % hg commit -m 'Initial commit'
~/repo1 % cd ..
~ % hg clone repo1 repo2
~ % cd repo1
~/repo1 % hg rename file file1
~/repo1 % hg commit -m 'Moved file'
~/repo1 % echo 'Goodye' > file1
~/repo1 % hg commit -m 'Bye'
~/repo1 % cd ../repo2
~/repo2 % hg transplant --source ../repo1 tip
searching for changes
applying 21aae71cc2e5
unable to find 'file1' for patching
1 out of 1 hunks FAILED -- saving rejects to file file1.rej
file1: No such file or directory
patch failed to apply
abort: Fix up the merge and run hg transplant --continue
Am I right?
Daniel.
--
No trees were killed in the generation of this message. A large number
of electrons were, however, severely inconvenienced.
More information about the Mercurial
mailing list