mercurial - Hg Mercurial 的修订历史记录记录在源代码中

标签 mercurial tortoisehg

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

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

此类功能的 HG 等效项是什么?

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

最佳答案

回答您的问题:

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


建议:不要这样做。

这让 merge 变得令人头疼,而在 Mercurial 中,您(可能)会一直进行 merge 。

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

所以,我再次建议不要使用该扩展。

作为您将遇到的令人头疼的问题的一个示例,在每次 merge 中都会有一个区域发生冲突,并且需要手动解决每个文件

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


要启用此扩展,请将其添加到 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 中(而不是全局)启用每个存储库的扩展名,并谨慎调整 [关键字] 文件名模式。

(以上内容复制自 KeywordExtension documentation

关于mercurial - Hg Mercurial 的修订历史记录记录在源代码中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23382777/

相关文章:

security - 如何设置 Mercurial Security.. 特别是用户

Git 相当于 hg purge

mercurial - 必须是 root 才能推送/提交到 Mercurial 存储库

version-control - Mercurial和Notepad++集成

mercurial - 如何使用草龟hg "that are part of the repository"忽略窑炉/ Mercurial 中的文件

mercurial - 获取 Mercurial 下一次提交哈希

git - 具有文件状态的 Mercurial 日志格式

mercurial - Vista 64 位中的 TortoiseHg 不显示上下文菜单

Tortoise 上的 Mercurial HG 卡住 - 等待锁定工作目录

mercurial - Mercurial : How to walk through changsets incrementally?