Like many people, I have several SVN repositories that contains several projects. I've decided to convert one of these repositories to Mercurial for several reasons.
I've successfully converted the repository using instructions located here. The new hg repo includes everything; all history and the correct tags. The conversion worked great.
Now, I need to "diverge" the two projects but I want to maintain the history on both sides. I'm wondering if there is a way to do this appropriately to prevent things like accidentally importing the changesets in to the others repository down the road.
To be clear, I don't care that each repository will have the same history for the current change set back (in fact, I want this). I just want to somehow indicate that they are "different" repositories from now on...
Update: Can someone elaborate on the --force? At what point will that flag be necessary. At http://www.selenic.com/mercurial/hg.1.html, under "pull", I see that the -f, --force options are to "run even when remote repository is unrelated" but what makes a repository unrelated? To me, since I cloned from the original repository they are (or could be) related....
Update: What I'm trying to prevent is allowing one repo to be pulled in to the other repo after some time has passed. (Which is now the case.) I wrote a script that produce the problem. And accomplishes exactly what I don't want to happen (It's a windows batch file):
@echo off
REM - First, create two distinct repos.
REM - Add some files to each.
MD test1
MD test2
cd test1
hg init
REM - Do several writes and commits to give content to the repo.
echo This is some text for test1 > test1.txt
echo This iss some more text; blah blah; >> test1.txt
echo Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer sapien velit, hendrerit sit amet ultrices nec, malesuada a mauris. Mauris eget nisi sit amet diam sodales tristique nec at turpis. Nam viverra pulvinar est, quis accumsan nunc fringilla ut. Nullam eu massa sapien, ac molestie magna. Curabitur nec pharetra nibh. Pellentesque velit dui, placerat vel porta eget, malesuada vitae dolor. In a lectus vel sapien imperdiet fringilla quis eu odio. Donec pellentesque ante nec est iaculis a aliquam nibh varius. Vivamus sit amet dolor non lorem ullamcorper ultricies quis in risus. Mauris eget orci leo. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut lorem lacus. In hac habitasse platea dictumst. Mauris pellentesque purus non elit molestie vehicula. >> test1.txt
echo This is another text file for test1 > test2.txt
hg addremove
hg commit -m"First commit on test1"
echo Nunc mollis, neque vel tempus iaculis, eros erat egestas metus, vitae condimentum tortor tortor id sem. Integer ac ante quis nisl condimentum iaculis. Vestibulum et quam vel lectus porta ultricies. Donec ultricies dignissim sollicitudin. Morbi sit amet est urna, a bibendum felis. In aliquet, tortor nec consequat ultricies, sapien diam eleifend nulla, in ullamcorper eros sapien ac magna. Phasellus sit amet congue quam. Nulla gravida justo aliquam libero tristique non tempor nunc mollis. Suspendisse venenatis tincidunt massa, a tempus odio blandit non. Suspendisse egestas orci lorem. Curabitur bibendum nibh quis elit tempus id suscipit nisl viverra. Pellentesque placerat nisl at felis porta laoreet. >> test1.txt
hg commit -m"second commit on test1"
echo Nunc placerat cursus scelerisque. Sed ac magna lacus, quis facilisis elit. Praesent mattis purus in urna congue auctor. Fusce pellentesque scelerisque dictum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus vulputate nunc quis ante laoreet posuere. Curabitur ante turpis, blandit vitae dapibus vitae, convallis at tortor. Sed augue leo, fermentum id consequat et, accumsan in neque. In pellentesque luctus nisi, ac sagittis nisl condimentum tincidunt. Cras nec dui vitae purus adipiscing consectetur id at mi. Vestibulum quis est vitae purus dictum mollis. Phasellus ultrices rhoncus eleifend. Sed sit amet euismod orci. Curabitur id turpis tortor, nec mollis neque. Praesent egestas augue vitae sem fringilla at molestie lacus venenatis. >> test1.txt
hg commit -m"thrid commit on test1"
echo Suspendisse nec porta velit. Donec aliquet mi vel felis tempor vehicula vitae interdum quam. Phasellus tempor orci at ligula adipiscing sagittis. Quisque faucibus accumsan dui vel facilisis. Pellentesque laoreet quam vel nisl mattis ac venenatis sapien suscipit. Nam eget dictum risus. Proin quam magna, volutpat quis congue vitae, dapibus et mi. Etiam tempus purus ut massa sodales sed cursus odio ultrices. Ut vel dictum urna. Fusce blandit dignissim nibh a tempus. Nullam libero arcu, feugiat vel sollicitudin vitae, lacinia pulvinar enim. Nulla hendrerit faucibus tortor, sit amet convallis velit vehicula ut. Cras leo sem, fermentum eu adipiscing non, bibendum et lacus. Nulla volutpat tortor non libero feugiat fermentum id quis sem. Vivamus lobortis nibh quis diam semper feugiat. Phasellus ac lobortis purus. Vivamus at mi sem. Quisque accumsan consequat placerat. >> test1.txt
hg commit -m"fourth commit on test1"
cd ..
cd test2
hg init
echo Nala is a cat >> myCats.txt
hg addremove
hg commit -m"first commit on test2"
echo Simba is a cat >> myCats.txt
hg commit -m"2nd commit on test2"
echo Nanoon is a cat >> myCats.txt
hg commit -m"3rd commit on test2"
cd ..
REM ------------------------------------------------------------------------------------------------------------------------------------------------------
hg clone --pull test1 test-combined
cd test-combined
hg pull ../test2
echo -
echo You should have gotten a "abort: repository is unrelated" error.
echo this is from attempting to pull test2 in to the test-combined. Can't without --force flag.
echo This is another file for combined repo > combinedRepo.txt
echo This should be unique to test-combined >> combinedRepo.txt
hg addremove
hg commit -m"1st Change to combined repo"
echo Fusce lectus arcu, cursus et dictum et, ultrices ut magna. Cras ultrices leo ac arcu commodo auctor. Pellentesque commodo sem et elit euismod posuere. Nam cursus, nisl ut placerat tincidunt, diam ante congue felis, id facilisis sem eros nec augue. Phasellus vel interdum est. Nunc at tellus non dui aliquam placerat nec placerat augue. Vestibulum justo sem, laoreet et blandit eu, mollis a nibh. Cras convallis, turpis quis vulputate euismod, risus neque convallis dui, posuere eleifend dolor quam ut dui. Integer pharetra porttitor lorem, vitae commodo mi semper non. Duis ipsum nisi, vulputate vel cursus ut, consectetur eu tellus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Fusce lobortis quam molestie leo scelerisque blandit. Ut massa neque, dapibus rutrum porta et, molestie vitae augue. Mauris eu erat a turpis suscipit viverra. Praesent vitae ante non dui volutpat ullamcorper eu in nisl. >> combinedRepo.txt
hg commit -m"2nd Change to combined repo"
cd .hg
rem - Replace the hgrc file where we blank out the default file.
echo [paths] > hgrc
echo default = >> hgrc
cd ..
cd ..
REM - We are not back in the starting folder...
REM ------------------------------------------------------------------------------------------------------------------------------------------------------
cd test1
echo A third file to make yet another commit in the repo. > myThirdFile.txt
hg addremove
hg commit -m"a third file to make this (test1) different than test-combined"
cd ..
REM - Retry the pull - Same source but diverged repos.
cd test-combined
hg pull ../test1
ECHO -
ECHO The pull just executed (in test-combined) succeeded but we want to prevent this.
ECHO Here is the log for test-combined
hg log
cd ..
@echo on
To run this, create an empty directory and save the text in the code block in to a .cmd file. Open a command window and navigate to the file and execute the .cmd.
You'll see the following above the log text:
added 1 changesets with 1 changes to 1 files (+1 heads) (run 'hg heads' to see heads, 'hg merge' to merge)
The log text shows that the two repos were, indeed, combined. In my ideal solution, this would have resulted in an error or a request for the --force flag.
Update (9/10/2009): The hg convert
didn't work for what I needed.