如何在Mercurial中显示未应用的更改集列表

时间:2011-07-05 11:31:45

标签: mercurial push

将变更集推送到名为“A”的存储库后,如何在“A”中查看等待应用的变更集列表?

扩展,

  1. 在回购B中,我将变更集推送到回购B
  2. 我改为回购B
  3. 如何列出步骤1中推送的更改集?

3 个答案:

答案 0 :(得分:8)

不确定“未应用”更改集的含义,但是这里有几个想法。

在执行hg outgoing之前,您可以通过hg push轻松查看将哪些更改集推送到存储库。这将列出将使用默认选项推送的所有更改集。

同样,您可以在目标存储库中使用hg incoming来显示从另一个存储库中提取的更改集。

对于“未应用”的变更集,如果我假设你的意思是比工作目录更新的变更集,你可以使用hg log -r .:tip,这应该(我没有机会测试它)显示所有更新修订,但实际上并非所有最近推动的修订。

编辑:我已将-r选项中的修订版本更新为应该有效的内容。请查看Mercurial manpage上的revsets,了解更多可能性。

答案 1 :(得分:5)

$ hg summary
parent: 0:9f47fcf4811f 
 .
branch: default
commit: (clean)
update: 2 new changesets (update) <<<<<

update位告诉你(我认为)你想要什么。

答案 2 :(得分:1)

I had written a different answer, but I ended up with a better way of doing what is needed here (an even better and definitive –for me– solution is at the end of this post, in the [EDIT] section).

Use hg log.

Specifically, issue an hg sum command first. This will give me:

parent: 189:77e9fd7e4554
 <some commit message>
branch: default
commit: (clean)
update: 2 new changesets (update) 

To see what those 2 new changesets are made of, I use

hg log -r tip -r 2 -v

Obviously, 2 is to be replaced with the number of changesets that hg sum reports.

This works because tip will refer to the most recent (or "unapplied") changeset. By limiting the output to the 2 latest changes (-l 2), the information is shown only for those changesets that I'm interested in. With -v, the list of files affected by the changeset is also shown.

To make things simpler, I have defined a user command in my .bashrc file:

alias hglog="hg log -r tip -l $1"

This allows me to type hg sum (to get the number of pending/unapplied changesets) and then to type hglog x where x is the number of changesets revealed by hg sum.

There is probably a more complete way of doing this, for instance using custom templates, but I guess it's pushing things too far in terms of sophistication.

[EDIT] (Third iteration) I have reached the most satisfying answer to this question by expanding on the alias idea so that I no longer have to type hg sum. My .bashrc file now contains this:

show_pending_changesets() {
  nb=$(hg sum | grep "update:" | sed 's/update: \([0-9]*\) .*/\1/');
  if [ `expr $nb + 1 2> /dev/null` ] ; then
    hg log -r tip -v -l $nb
  else 
    echo "Nothing new to report"
  fi ;
}
...
alias hgwhatsnew=show_pending_changesets

Explanation: I'm using sed to extract the number of changesets from the last line (which is the one that starts with update:) of the output of hg sum. That number is then fed to hg log. All I have to do then is to type hgw and tab-complete it. HTH

相关问题