代码之家  ›  专栏  ›  技术社区  ›  Nate

关闭Hg分支

  •  92
  • Nate  · 技术社区  · 14 年前

    hg branch FeatureBranchName 将其发布到开发商之间共享的中央回购中,是否有办法最终关闭 FeatureBranchName 它的开发何时正式与默认分支合并?

    功能分支名称 在执行 hg branches 命令。

    2 回复  |  直到 14 年前
        1
  •  160
  •   Vadim Kotov First Zero    7 年前
    hg commit --close-branch
    

    应该足以标记一个分支关闭(看见 hg commit )

    --close-branch
    

    将分支标记为已关闭,将其从分支列表中隐藏。

    另请参见 this thread


    因此,当一个分支被关闭时,我不应该看到它(例如在分支、头、日志中),除非我明确要求查看关闭的分支。

    我应该注意到,我希望一个关闭的分支保留在存储库中; commit --close-branch 消息 至少应该解释一下分支机构为什么关闭。
    Pruning branches 完全是另一回事。


    注:“关店”业务是其中之一 aspect seen as missing in Git, when compared to Mercurial :

    git中的分支总是被告知,可以被使用和扔掉的只是昙花一现的东西,据我所知,git没有办法向你的同事表明你已经完成了分支;
    唯一的方法是删除它,或者希望他们看到最终的合并提交,并理解分支已经关闭,无法进行进一步的开发。

        2
  •  8
  •   Roshan Poudyal    6 年前

    我编写了一个简单的脚本来完成分支关闭,命令可以在 PruningDeadBranches .

    #!/bin/bash
    #script to close the not required branch in mercurial
    
    hg up -C $1
    if [ $? -eq 0 ]; then
        echo "$1 is up"
    else
        echo "branch not found, please recheck your argument"
        exit 1
    fi 
    # if we are here then the branch is up, so we do the following
    hg commit --close-branch -m 'this branch no longer required' 
    echo "$1 is closed"
    hg up -C default
    echo "default is up" 
    

    如何

    移动到存储库的本地副本,并通过提供参数来运行此脚本。例如:

    $./the_script_above.sh bad_branch_name_to_close
    

    这将执行以下操作:

    1. 错误消息。
    2. 它关闭了分支。
    3. 停止。