如何插入或更改mercurial修订版

Asa*_*ers 8 mercurial hgsvn

我怎么能改变r0所以它看起来像我.hgignore在创建我的存储库时添加或在我当前之前插入提交r0

我刚刚使用hgsvn将一个庞大的SVN repo转换为mercurial.花了几个小时,不得不通过十几个分支来完成整个过程.我现在的问题.hgignore是没有提交,所以当我hgimportsvn成为一个分支时,它.hgignore似乎没有提供它.我想插入该文件作为其中的一部分r0或在其之前插入(并将所有内容移动1).我也尝试在我的Mercurial主干结账时提交它,但似乎hgimportsvn总是克隆(分支?)来自我的SVN分支创建的相同Mercurial修订版,因此.hgignore再次丢失.

Mar*_*nen 5

你可能需要像ConvertExtension这样的东西.看看--splicemap选项.

要创建一个新的历史记录,并将.hgignore文件添加为第一个修订版:

  1. 创建一个新的存储库,其唯一的修订是.hgignore提交.
  2. 创建一个包含两个40-char哈希的splicemap文件:当前数据库的rev 0和新数据库的rev 0.
  3. hg convert <current_db_dir> <new_db_dir> --splicemap splice_filename

这会将当前数据库中的每个修订添加到新数据库.splicemap指定编辑父项,因此如果当前数据库的修订版0将其父项设置为新数据库的修订版0.

下面是一个Windows批处理文件,它创建一个3版本的数据库和一个带有.hgignore文件的1版本数据库,将它们拼接在一起.结果应该是您正在寻找的.如果您拥有大型原始数据库,则可能需要一段时间,因为源数据库的整个历史记录将重新写入目标数据库.

@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
Run Code Online (Sandbox Code Playgroud)