如何更改r0
,使其看起来像在创建存储库时添加了.hgignore
或在当前r0
之前插入提交?
我刚刚使用hgsvn将大量的SVN repo 转换为 Mercurial 。它花费了几个小时,并且必须经过大约十二个分支才能了解整个过程。我现在的问题是.hgignore
未提交,因此当我对分支进行hgimportsvn
时,.hgignore
似乎不附带它。我想将该文件作为r0
的一部分插入或在其之前插入(并将所有内容移位1)。我也尝试过在Mercurial干线结帐的最后提交它,但是hgimportsvn
似乎总是从与我的SVN分支相同的Mercurial版本中克隆(分支),因此.hgignore
再次丢失。
最佳答案
您可能需要像ConvertExtension这样的东西。 checkout --splicemap
选项。
要使用添加的.hgignore文件作为第一个修订版本来创建新的历史记录,请执行以下操作:
hg convert <current_db_dir> <new_db_dir> --splicemap splice_filename
这会将当前数据库中的每个修订添加到新数据库中。 splicemap指定编辑父对象,因此,如果当前数据库的修订版0将其父对象设置为新数据库的修订版0。
下面是一个Windows批处理文件,该文件创建一个3修订数据库和1修订数据库,其中包含.hgignore文件,将它们拼接在一起。结果应该是您想要的。如果您的原始数据库很大,则可能要花一些时间,因为源数据库的整个历史记录都将被重写到目标数据库中。
@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
关于mercurial - 如何插入或更改 Mercurial 版,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3588695/