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

Matt Mackall mpm at selenic.com
Wed Dec 9 15:48:28 CST 2009


On Wed, 2009-12-09 at 16:41 -0500, Greg Ward wrote:
> On Wed, Dec 9, 2009 at 4:18 PM, Steve Losh <steve at stevelosh.com> wrote:
> > Would "hg log --template '{rev}\n' --rev B:0 --follow --prune A" do what you
> > need?
> 
> Yes, that seems to work.  I didn't know you could do that with --follow.  Huh.
> 
> But 1) I'm working in Python, not shell, so it's easier to make calls
> to the Mercurial API and 2) my repository has 104,000 changesets, so
> "--rev B:0" takes a while (~60 sec without --follow, ~130 sec with
> --follow).

You might find that -q makes it a lot faster (it just uses the index).

>   If A and B are only 100 changesets "apart" (whatever that
> means), I don't want to visit 104,000 changesets to find those 100.

I think the simplest way to do it is something like (untested):

cl = repo.changelog
a = set(cl.ancestors(A))
b = set(cl.ancestors(B))
revs = b - a

-- 
http://selenic.com : development and support for Mercurial and Linux




More information about the Mercurial-devel mailing list