【问题标题】:Mercurial - How to specify branch on commit?Mercurial - 如何在提交时指定分支?
【发布时间】:2012-02-20 00:29:28
【问题描述】:

当用户提交变更集时,我希望显示一条消息,提及提交变更集的分支。

例子:

$hg commit -m 'Fix bug'
Changeset committed on branch bugfix

我真的需要修改 hg 提交代码还是一种更快/更简单的方法?

【问题讨论】:

  • 值得注意的是,如果不使用-m快捷方式显示分支的注释。我知道这需要一秒钟的时间,但我避免使用 -m 正是因为我想查看显示在评论编辑器的评论块中的“将提交的内容以及它将去哪里”的列表。

标签: mercurial branch commit


【解决方案1】:

不幸的是,ssg 的答案不能移植到例如Windows(因为反引号),但这应该可以工作:

# UNIX-like
[hooks]
commit=hg log -r $HG_NODE --template "Committing on branch {branch}\n"

# Windows
[hooks]
commit=hg log -r %HG_NODE% --template "Committing on branch {branch}\n"

【讨论】:

  • @ssg 很公平 :-) 我没注意到。
【解决方案2】:

添加到您的存储库的 .hg/hgrc:

[hooks]
commit=echo "Changeset committed on branch `hg branch`"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-08
    • 1970-01-01
    • 2012-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-25
    相关资源
    最近更新 更多