0

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.

Community
  • 1
  • 1
sje
  • 117
  • 1
  • 9
  • 2
    I'm not entirely clear on your requirements. You want changes since 5, but also include 4 in this set? Is "since" meant to imply a chronological order or ancestry in the revision graph (note that 4 would be included in neither) or something else? – Reimer Behrends Nov 03 '15 at 20:39
  • Why is 6 omitted from the list of changes you want to see? And is there a reason why you don't just say all changes since 3 but excluding 3? – Nanhydrin Nov 04 '15 at 10:56
  • The reason I want to include 4 and 7 is because they are merged into the default branch at 9 and therefore they will be included as part of 10. 6 is not to be included because it was not merged back into the default branch and therefore is not included in 10. – sje Nov 04 '15 at 13:47

1 Answers1

1

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
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • Also note that I looking for the ancestors between 5 and 10 do the suggested command would be **hg log -r "ancestors(10) - ancestors(5)"**, which I modified to be **hg log -r "ancestors(10) - ancestors(p1(5))"** since the output was not inclusive of 5. – sje Nov 04 '15 at 15:31
  • @sje - In cleanly writen **my** bisiness-task (which *have* internal logic) 5 is a wrong bounary, and for `ancestors(p1(5)` I'm totally out of idea "that is it" in RL-terms – Lazy Badger Nov 04 '15 at 15:38