【问题标题】:How to view a single Mercurial commit from the command line?如何从命令行查看单个 Mercurial 提交?
【发布时间】:2012-10-29 19:50:03
【问题描述】:

我想从命令行查看给定 Mercurial 提交中的更改,类似于从 hg status 或 TortoiseHg 工具中看到的更改。我似乎能得到的最接近的是hg log --stat,但它会打印额外的符号(即加号和减号),我无法指定要查看哪个特定版本。

我需要这个,因为我的开发人员拥有像“.”这样的签入 cmets。或者 ”,”。 >:-(

【问题讨论】:

  • 你需要什么样的信息?从描述上看不太明显。
  • hg status 提供的那种信息,但是对于过去的修订......然后我发现hg status 也可以提供历史信息。不幸的是,我已经发布了这个问题并且浪费了相当长的时间来处理来自hg log 的值。

标签: command-line mercurial mercurial-commit


【解决方案1】:

事实证明 hg status 有一个 --change 参数,您可以在其中传递修订号(例如 109)、相对修订(即 -1 是最后一次提交,-2 是倒数第二个等),或者对其修订的哈希值,它将打印出修订所具有的更改(即添加、删除和修改)。

--change 隔离该修订版并仅显示该修订版,但将 --change 替换为 --rev 显示自该修订版到当前状态的累积效果。

【讨论】:

  • 换句话说,--change X == --rev "p1(X):X"
【解决方案2】:
hg log -v -r <changeset>

changeset:   563:af4d66e2bc6e
tag:         tip
user:        David M. Carr <****>
date:        Fri Oct 26 22:46:02 2012 -0400
files:       hggit/gitrepo.py tests/test-pull.t
description:
pull: don't pull tags as bookmarks

或者,使用模板,类似

hg log -r tip --template "{node|short} - files: {files}\n"

有输出

af4d66e2bc6e - files: hggit/gitrepo.py tests/test-pull.t

【讨论】:

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