mercurialmercurial-revsets

Mercurial log that includes the ancestry of a final revision but excludes anything on the default branch prior to the starting revision


I am working on a script that parses a mercurial log and generates a report of all changes between any two revisions. In order to handle branches, I believe I need to use revsets to generate ancestry of the final revision but I want to limit the scope to exclude any revisions which are ancestors to the starting revision.

   10
  /
 / 
9
|\
| \
|  \
8   | 
|   7
| 6 |
|/  |   
5   4
|  / 
| /
|/
3 
|   
| 
|
2
|
|
|
1

At 3, a feature branch is created from the default branch.

At 5, a release branch (6) is created from the default branch.

At 9, the feature branch is merged back to default and a new release (10) is created.

I want a list of all changes since 5 that affect 10 => 4,5,7,8,9,10

The difficulty I am having is limiting the ancestry search when 3 is reached via the feature branch. I don't want it since 3 was already a part of 5.

Other discussions I reviewed:

Close but didn't help with limiting the scope.

This one implies you know the branch but I need to find them all dynamically.


Solution

  • OK, if your business-task is "What's new in release", best iteration of revset will be ancestors(LAST) - ancestors(PREVIOUS), i.e. for your sample

    hg log -r "ancestors(10) - ancestors(6)"
    

    (note missing r5 in output, because it was in 6)

    maybe revset will be more usable in [revsetalias] with alias added for better readability, smth.like (untested!!!)

    [revsetalias]
    new($1,$2) = ancestors($1) - ancestors($2)
    
    [alias]
    cl = log -r "new($1,$2)" --style changelog