【问题标题】:Hg Mercurial's Revision History logs in source codeHg Mercurial 的修订历史记录在源代码中
【发布时间】:2014-04-30 08:05:45
【问题描述】:

我刚刚将我的源代码从 SVN 迁移到 HG Mercurial。

使用 SVN,如果您将某些关键字作为注释,则可以在源代码中添加提交消息。通常,它被添加在源代码的顶部或底部。 例子: /* * 修订:$Revision$ */

这种功能的 HG 等效项是什么?

我希望在文件中包含修订历史记录,而不必去 Hg 查看历史记录。这可能吗?

【问题讨论】:

    标签: mercurial tortoisehg


    【解决方案1】:

    回答你的问题:

    您可以使用KeywordExtension 扩展名。它允许您在文件中使用类似 CVS 的关键字扩展。


    建议:不要这样做。

    合并令人头疼,而在 Mercurial 中,您(可能)会一直进行合并

    此外,history 的关键字将扩展为线性历史转储,而您的真实 Mercurial 历史不是线性的,它是并行的,这使得文件中的历史转储具有误导性。它可能会导致一段历史,该历史显然在实现该功能之前修复了一个错误。

    同样,我建议不要使用该扩展程序。

    作为您将遇到的那种头痛的示例,您将有一个区域在每次合并中都会发生冲突,并且需要手动解决in每个文件

    但是,如果你还想启用它,上面的页面有以下详细信息:


    要启用此扩展,请将其添加到 hgrc 文件中的“[extensions]”节中:

    [extensions]
    keyword=
    #or, if keyword.py is not in the hgext folder:
    #keyword=/path/to/keyword.py
    

    其他配置在配置文件的 [keyword] 和 [keywordmaps] 部分完成:

    # filename patterns for expansion are configured in this section
    [keyword]
    # expand keywords in all python files in working dir
    **.py =
    # do not expand keywords in files matching "x*" in working dir
    x* = ignore
    ...
    # override the cvs-like default mappings with customized keyword = expansion pairs,
    # where expansion values contain Mercurial templates and filters
    [keywordmaps]
    HGdate = {date|rfc822date}
    lastlog = {desc}
    checked in by = {author}
    
    • 出于速度和安全原因(避免无意中扩展的关键字),建议仅在 repo/.hg/hgrc 中启用每个 repo 的扩展名,而不是全局启用,并非常小心地微调 [keyword] 文件名模式。

    (以上内容复制自KeywordExtension documentation

    【讨论】:

    • 真的:不要这样做。它与 mercurial 的工作方式是对立的。如果您想要 SVN,请使用 SVN。 (+1)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-29
    • 2014-08-25
    • 2011-02-10
    相关资源
    最近更新 更多