开发者

What is the Mercurial equivalent for showing commits in one branch but not in another?

开发者 https://www.devze.com 2023-04-12 01:35 出处:网络
In git, I can do the following: git log foo ^bar to show changesets in the branch foo but not in the branch bar. Is there a way to do that in Mercurial?

In git, I can do the following:

git log foo ^bar

to show changesets in the branch foo but not in the branch bar. Is there a way to do that in Mercurial?

Edit: To explain a little more the use case. Say I have a branch in Mercurial (call it foo) that is branched off of default. What I want to know is what commits are in the foo branch, and therefore haven't been merged to default. Maybe I'm thinking of this the wrong way, but in git,开发者_如何学Python I could start working on foo, merge to master and then work some more on foo and use the command above to see which commits had yet to be merged in.

So a specific use case is knowing whether a branch has been completed merged into default. From using Mercurial, if I start a branch foo off of default to work on one feature, then leave it there so be merged and branch off of foo to create bar, which contains another feature built on top of things in foo, foo ends up being inactive because bar contains all the changesets in foo, but I may want to merge just the changesets in foo because I know those are good while bar is still in development. Hopefully that's helpful.


Try using revsets (hg help revsets)

hg log -r "branch(foo) and not branch(bar)"

But this is kind of useless as a changeset can only be in one named branch at a time.

Maybe you mean all ancestors of a bookmark that are not ancestor of another bookmark?

hg log -r "::a and not ::b"

Either way, the revsets help page should get you started.


What exactly do you mean by commits in branch foo but not in bar? Commits are fundamentally only in one branch in mercurial.

hg log -b foo  #lists all commits that are in branch foo


to show changesets in the branch foo but not in the branch bar

hg log -r "::foo and not ::bar and ! destination(branch(bar)) and ! origin(branch(bar))"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号