API question: ancestors of B that are not ancestors of A

Greg Ward greg-hg at gerg.ca
Wed Dec 9 15:04:16 CST 2009

Hi all --

here's my problem: imagine a customer is running software built from
changeset A, and we want to upgrade them to a new version, built from
changeset B.  So I need to know what bugs are fixed in B that were not
fixed in A.  I have already implemented a changeset/bug mapping, so I
can trivially lookup the bugs fixed by any changeset.  (It even handles
"ongoing" and "reverted" bugs in addition to "fixed".)

The high-level algorithm is thus:

  1. find all nodes that are ancestors of B but not ancestors of A
  2. lookup the bugs fixed by all those nodes
  3. print the list

#1 is the tricky part.  Before you stick up your hand and say "ooh! ooh!
I know, use revlog.nodesbetween()!", it's not so simple.  Here is the
tricky case:

                  +--- 75 -- 78 -- 79 ------------+
                 /                                 \
                /     +-- 77 -- 80 ---------- 84 -- 85
               /     /                        /
  0 -- ... -- 74 -- 76                       /
                     \                      /
                      +-- 81 -- 82 -- 83 --+

There are lots of easy (A, B) pairs here: e.g. if we want to upgrade the
customer from rev 81 to rev 83, nodesbetween() is just fine (after
removing 81 from the list, of course, because the customer already has the
fixes in 81).

But imagine we want to upgrade someone from 81 to 85.  In that case,
nodesbetween() will just return [81, 82, 83, 84, 85].  But that is
missing a number of nodes: "ancestors of 85 that are not ancestors of
81" also includes 75, 78, 79, 77, and 80, so we need to include all of
their bug fixes in the final result.

So: does the code for "find all ancestors of B that are not ancestors of
A" already exist somewhere in Mercurial?  Or do I have to write it

Thanks --


More information about the Mercurial-devel mailing list