如何让 Mercurial 在“hg com”期间显示差异?

发布于 2024-08-30 09:15:13 字数 166 浏览 6 评论 0原文

有没有办法配置 hg com 以便在外部编辑器中弹出的提交消息文件中,而不是仅显示哪些文件已更改(在 HG: 中)行)它实际上显示了完整的差异?我宁愿在文本编辑器中同时查看输出并撰写提交消息,而不是事先在命令行上单独执行 hg diff

Is there a way to configure hg com so that in the commit message file that pops up in the external editor, instead of just showing which files were changed (in the HG: lines) it actually shows the full diff? I'd rather view the output and compose my commit message simultaneously from the comfort of my text editor as opposed to doing hg diff on the command line separately beforehand.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

最单纯的乌龟 2024-09-06 09:15:14

截至 2016 年,可以使用 committemplate 配置选项来完成此操作。将以下内容添加到 hgrc 文件中将在您键入提交消息时将差异包含在编辑器窗口中。

[committemplate]
changeset = {desc}\n\n
    HG: {extramsg}
    HG: user: {author}\n{ifeq(p2rev, "-1", "",
   "HG: branch merge\n")
   }HG: branch '{branch}'\n{if(currentbookmark,
   "HG: bookmark '{currentbookmark}'\n")  }{subrepos %
   "HG: subrepo {subrepo}\n"              }
   {splitlines(diff()) % 'HG: {line}\n'}

请参阅 hg help hgrc 并搜索 committemplate 了解更多信息。

As of 2016, it's possible to do this with the committemplate configuration option. Adding the following to an hgrc file will include the diff in the editor window inline as you type your commit message.

[committemplate]
changeset = {desc}\n\n
    HG: {extramsg}
    HG: user: {author}\n{ifeq(p2rev, "-1", "",
   "HG: branch merge\n")
   }HG: branch '{branch}'\n{if(currentbookmark,
   "HG: bookmark '{currentbookmark}'\n")  }{subrepos %
   "HG: subrepo {subrepo}\n"              }
   {splitlines(diff()) % 'HG: {line}\n'}

See hg help hgrc and search for committemplate for more information.

岁月静好 2024-09-06 09:15:14

Mercurial 没有将其作为内置功能,但很容易在编辑器中进行模拟(通过提交启动)。

以下是使用 VIM 的示例: https://www.mercurial-scm.org/wiki/DiffsInCommitMessageInVIM< /a>

hgeditor 脚本 https://www. Mercurial-scm.org/hg/hg-stable/raw-file/tip/hgeditor 提供了更多示例。

基本要点是:

  1. 在编辑器启动时运行 hg diff 重定向到临时文件
  2. 让您的编辑器加载提交消息文件和 diff

Mercurial doesn't have that as a built-in feature, but it's easy to simulate in your editor (as launched by commit).

Here's an example using VIM: https://www.mercurial-scm.org/wiki/DiffsInCommitMessageInVIM

The hgeditor script https://www.mercurial-scm.org/hg/hg-stable/raw-file/tip/hgeditor provides further examples.

The basic jist is:

  1. at editor launch run hg diff redirecting to a temp file
  2. have your editor load both the commit message file and the diff
执手闯天涯 2024-09-06 09:15:14

TortoiseHg 开箱即用:顶部面板用于提交消息,其下方是左侧面板列表受影响的文件和右窗格依次显示差异。

TortoiseHg does this out of the box: a top panel for the commit message and below that, a left pane listing the affected files and a right pane showing the diffs, one after the other.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文