代码之家  ›  专栏  ›  技术社区  ›  Asa Ayers

如何插入或更改Mercurial修订

  •  8
  • Asa Ayers  · 技术社区  · 14 年前

    我怎样才能改变 r0 所以看起来像是我加的 .hgignore 当我创建存储库或在当前存储库之前插入提交时 R0 ?

    我刚用hgsvn把一个巨大的svn repo转换成mercurial。花了好几个小时,不得不穿过十几个树枝才能弄到整件事。我现在的问题是 HG忽略 没有承诺,所以当我 hgimportsvn 一个分支 HG忽略 好像没有。我想插入那个文件作为 R0 或者在这之前插入(并将所有内容移动1)。我也试过在我变化多端的后备箱结账时提交,但似乎 HGCPIN 总是克隆(分支?)从同一个Mercurial修订版创建了我的SVN分支 HG忽略 又迷路了。

    2 回复  |  直到 7 年前
        1
  •  5
  •   CharlesB Craig McQueen    8 年前

    你可能需要这样的东西 ConvertExtension . 退房 --splicemap 选择权。

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

    1. 创建一个新的存储库,其唯一修订版本是.hgignore commit。
    2. 创建一个包含两个40个字符哈希的拼接映射文件:当前数据库的Rev 0和新数据库的Rev 0。
    3. hg convert <current_db_dir> <new_db_dir> --splicemap splice_filename

    这会将当前数据库中的每个修订添加到新数据库中。拼接图指定父级的编辑,因此如果当前数据库的修订版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
    
        2
  •  0
  •   Vadim Kotov First Zero    7 年前

    也许您可以提交.hgignore,然后将提交重新设置为历史的开头(请参见 https://www.mercurial-scm.org/wiki/RebaseProject )

    推荐文章