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:
- Create a new repository whose only revision is the .hgignore commit.
- Create a splicemap file containing two 40-char hashes: rev 0 of your current database, and rev 0 of your new database.
- Run "hg <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 parrent 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