With Mercurial, how do you hg log a branch with cross-branch ancestors?

余生颓废 提交于 2020-01-13 18:25:11

问题


In Mercurial, I'm wanting to build a changelog of all commit messages for revisions my stable branch. Currently, I'm using:

hg log -r <oldid>::<newid>

where is the revision id of the changeset from the last time we pushed out code, and is stable's tip. This works great for code changes that are only on the stable branch, but if I'm merging another branch (such as a new major version which had its own development branch), all those commit messages are omitted! Instead I only get the 1 commit from where it merged into stable. I would like some way (preferably w/ hg log) to see these as well.

I do NOT want to get any "unpublished" commits in this list - that is, commits on any branches which haven't been merged into stable.

Here is an example of what I'm looking for:

In this example, the last pushed revision is 540. Because of this, I don't want anything at 540 or below. There are several branches out into default and back in to stable, and I want all of these (539, 541-557 in green). However, there are some changes NOT merged back into stable (558-563) which I wish to omit. Pay special attention to Revision 539; it was NOT merged into stable when 540 was published, and therefore was not included. But now it has since been merged into stable, so I would like to include it!

Any advice you guys have would be greatly appreciated. Thanks!


回答1:


Not 100% sure if this will work:

hg log -r '::stable - ::540'

I'm uncertain about it because I would have thought the command you provided would mostly be correct, except for changeset 539. You're not passing -b stable to hg log by mistake, are you?




回答2:


Have a look at revsets. Kevin posted the short form of what you want - here's the long form:

hg log -r "ancestors('stable') and not ancestors(540)"

Revsets are incredibly powerful, and you can just enter them into the filter bar of TortoiseHg.



来源:https://stackoverflow.com/questions/26934373/with-mercurial-how-do-you-hg-log-a-branch-with-cross-branch-ancestors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!