如何在 Mercurial 中显示未应用的变更集列表
将变更集推送到名为“A”的存储库后,当我位于“A”时,如何查看等待应用的变更集列表?
扩展一下,
- 在存储库 BI 中将变更集推送到存储库 B
- 我更改为存储库 B
- 如何列出步骤 1 中推送的变更集?
After pushing changesets to a repository called 'A' how can I see the list of changesets waiting to be applied when I am in 'A'?
Expanding on that,
- In repo B I push changesets to repo B
- I change to repo B
- How can I list the changesets pushed in step 1?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不确定“未应用”变更集是什么意思,但这里有一些想法。
在执行
hg Push
之前,您可以通过执行hg Outgoing
轻松查看哪些变更集将被推送到存储库。这将列出将使用默认选项推送的所有变更集。同样,您可以在目标存储库中使用
hgcoming
来显示将从另一个存储库中提取哪些变更集。至于“未应用的”变更集,如果我假设您的意思是比工作目录更新的变更集,您可以使用 hg log -r .:tip ,这应该(我没有机会测试它)显示所有较新的修订,但实际上并不是所有最近推送的修订。
编辑:我已将
-r
选项中的修订集更新为应该可以工作的内容。请查看 Mercurial 联机帮助页 上的转速集,了解更多可能性。Not sure what you mean by "unapplied" changesets, however here's a couple thoughts.
You can easily see what changesets will be pushed to a repository by doing
hg outgoing
prior to doing thehg push
. This will list all of the changesets that will be pushed using default options.Similarly you can use
hg incoming
in the destination repository to show what changesets would be pulled from another repo.As for "unapplied" changesets, if I assume you mean changesets that are newer than the working directory, you could use
hg log -r .:tip
, which should (I've not had a chance to test it) show all newer revisions, but not actually all recently-pushed ones.Edit: I've updated the revision set in the
-r
option to something that should work. Have a look at revsets on the Mercurial manpage for more possibilities.update
位告诉您(我认为)您想要什么。The
update
bit tells you what (I think) you want.我写了一个不同的答案,但我最终找到了一种更好的方法来完成这里需要的事情(对我来说,更好且明确的解决方案位于本文末尾的[编辑]部分)。
使用
hg log
。具体来说,首先发出
hg sum
命令。这将给我:要查看这 2 个新变更集的组成,我使用
显然,
2
将替换为hg sum
报告的变更集数量。这是有效的,因为
tip
将引用最新的(或“未应用的”)变更集。通过将输出限制为 2 个最新更改 (-l 2
),仅显示我感兴趣的那些更改集的信息。使用-v
时,列表还显示了受变更集影响的文件数量。为了让事情变得更简单,我在
.bashrc
文件中定义了一个用户命令:这允许我输入
hg sum
(以获取待处理/未应用的变更集的数量)并然后输入hglog x
,其中x
是hg sum
显示的变更集数量。可能有一种更完整的方法可以做到这一点,例如使用自定义模板,但我想它在复杂性方面太过分了。
[编辑](第三次迭代)
通过扩展别名的想法,我已经得到了这个问题最令人满意的答案,这样我就不再需要输入
hg sum
。我的 .bashrc 文件现在包含以下内容:说明:我正在使用
sed
从最后一行(即以update:
开头的行)中提取变更集的数量hg sum
的输出。然后将该数字输入到hg log
。我所要做的就是输入hgw
并按 Tab 键补全。华泰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:To see what those 2 new changesets are made of, I use
Obviously,
2
is to be replaced with the number of changesets thathg 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:This allows me to type
hg sum
(to get the number of pending/unapplied changesets) and then to typehglog x
wherex
is the number of changesets revealed byhg 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:Explanation: I'm using
sed
to extract the number of changesets from the last line (which is the one that starts withupdate:
) of the output ofhg sum
. That number is then fed tohg log
. All I have to do then is to typehgw
and tab-complete it. HTH