How can I alter r0
so it looks like I added .hgignore
when I created my repository or insert a commit before my current r0
?
I just converted a huge SVN repo using hgsvn to mercurial. It took several hours and had to go through about a dozen branches to get the whole thing. My problem now is that .hgignore
isn't committed, so when I hgimportsvn
a branch, the .hgignore
doesn't seem to come with it. I would like to insert that file as part of r0
or insert it before that (and shift everything by 1). I've also tried committing it at the end of my Mercurial trunk checkout, but it seems hgimportsvn
always clones (branches?) from the same Mercurial revision my SVN branch was created from so .hgignore
is lost again.
Pull changes from the Mercurial upstream (Pull)From the main menu, choose Hg | Mercurial | Pull. Specify the required URL address of the source remote repository.
Mercurial groups related changes to multiple files into single atomic changesets, which are revisions of the whole project. These each get a sequential revision number. Because Mercurial allows distributed parallel development, these revision numbers may disagree between users.
The tip is the changeset added to the repository most recently. If you have just made a commit, that commit will be the tip. Alternately, if you have just pulled from another repository, the tip of that repository becomes the new tip. Use hg tip to show the tip of the repository.
You probably need something like the ConvertExtension. Check out the --splicemap
option.
To create a new history with a .hgignore file added as the first revision:
hg convert <current_db_dir> <new_db_dir> --splicemap splice_filename
This adds each revision in the current database to the new database. The splicemap specifies editing of parents, so if revision 0 of the current database gets its parent set to revision 0 of the new database.
Below is a Windows batch file that creates a 3-revision database and a 1-revision database with an .hgignore file in it, the splices them together. The result should be what you are looking for. If you have a large original database it could take a while, since the entire history of the source database is re-written to the destination database.
@echo off
@REM Create a 3-revision database
hg init current
cd current
echo >file1
hg add
hg ci -m file1
echo >file2
hg add
hg ci -m file2
echo >file3
hg add
hg ci -m file3
@REM Add the first revision to the splice map
hg log -r 0 --template "{node} " > ..\map
@REM Display the result
hg log
cd ..
@REM Create a 1-revision database
hg init ignore
cd ignore
echo glob:*.txt>.hgignore
hg add
hg ci -m ignore
@REM Specify this node as the parent of the other
@REM database's first revision in the splice map
hg log -r 0 --template "{node}\n" >> ..\map
hg log
cd ..
@REM Here's the resulting splice map
type map
@REM Make a copy to store the result
hg clone ignore result
@REM Add revisions from "current" to "result" honoring
@REM the splice map
hg convert current result --splicemap map
@REM Display the result
cd result
hg log
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With