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

415 views Asked by At

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: HG Graph example

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!

2

There are 2 answers

1
Kevin On BEST ANSWER

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?

0
Tim Delaney On

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.