Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit » JGit RevWalk.isMergedInto()
JGit RevWalk.isMergedInto() [message #1058575] Tue, 14 May 2013 09:42 Go to next message
Rüdiger Herrmann is currently offline Rüdiger Herrmann
Messages: 563
Registered: July 2009
Senior Member
Hi,

I am struggling with RevWalk.isMergedInto(). The two tests below
(should) essentially create the same repository structure:
1. a common ancestor
2. two independent commits (master and topic) with 1. as parent
3. a merge commit of 'master' and 'topic'
4. an 'extra' commit with the merge commit as parent

With this setup, isMergedInto(master, extra) should return true. But for
some reason which I can't figure out, only the first test returns true.

Can anyone point me to what's wrong with the second test?

Both tests require to be members of a class that inherits from
RevWalkTestCase. You may just paste them into the RevWalkMergeBaseTest.

@Test
public void testIsMergedInto1() throws Exception {
RevCommit common = commit();
RevCommit master = commit(common);
RevCommit topic = commit(common);
RevCommit merge = commit(master, topic);
RevCommit extra = commit(merge);

boolean merged = rw.isMergedInto(master, extra);

assertTrue(merged);
}

@Test
public void testIsMergedInto2() throws Exception {
Git git = new Git(db);
git.commit().setMessage("common ancestor").call();
git.branchCreate().setName("topic").call();
RevCommit master = git.commit().setMessage("master commit").call();
git.checkout().setName("topic").call();
git.commit().setMessage("topic commit").call();
git.merge().include(db.getRef("master")).call();
RevCommit extra = git.commit().setMessage("extra commit").call();

boolean merged = rw.isMergedInto(master, extra);

assertTrue(merged);
}

I suspect I am missing something very obvious...
TIA
Rüdiger
Re: JGit RevWalk.isMergedInto() [message #1060232 is a reply to message #1058575] Thu, 23 May 2013 11:58 Go to previous messageGo to next message
Stefan Lay is currently offline Stefan Lay
Messages: 340
Registered: July 2009
Senior Member
I don't yet know why the second test fails, but I can make it work if I change the assert to

boolean merged = rw.isMergedInto(rw.lookupCommit(master),
rw.lookupCommit(extra));

Somehow the revwalk does not correctly walk the topology.
Re: JGit RevWalk.isMergedInto() [message #1060437 is a reply to message #1060232] Fri, 24 May 2013 11:52 Go to previous messageGo to next message
Robin Rosenberg is currently offline Robin Rosenberg
Messages: 319
Registered: July 2009
Senior Member
Stefan Lay skrev 2013-05-23 17.58:
> I don't yet know why the second test fails, but I can make it work if I change the assert to
> boolean merged = rw.isMergedInto(rw.lookupCommit(master),
> rw.lookupCommit(extra));
>
> Somehow the revwalk does not correctly walk the topology.

I think it is this: Here, and in general, when a method accepts a RevObject of some kind,
(and possibly a RevWalk) it means all objects must be allocated by the same RevWalk instance.
The javadoc should mention this.

-- robin
Re: JGit RevWalk.isMergedInto() [message #1060602 is a reply to message #1060437] Mon, 27 May 2013 05:27 Go to previous messageGo to next message
Stefan Lay is currently offline Stefan Lay
Messages: 340
Registered: July 2009
Senior Member
> I think it is this: Here, and in general, when a method accepts a RevObject of some > kind,
> (and possibly a RevWalk) it means all objects must be allocated by the same RevWalk > instance.
> The javadoc should mention this.

I agree. We should also mention this in the JavaDoc of the Git API methods returning a RevObject.

Stefan
Re: JGit RevWalk.isMergedInto() [message #1060959 is a reply to message #1060437] Wed, 29 May 2013 06:12 Go to previous message
Rüdiger Herrmann is currently offline Rüdiger Herrmann
Messages: 563
Registered: July 2009
Senior Member
thanks for your help, that hint brought my code to work.
I find documenting that RevCommits cannot be mixed with arbitrary
RevWalks a rather weak measure. The API would become easier to use if
this limitation was removed. Or - if that's not feasible - at least an
exception would be thrown.

Regards,
Rüdiger

On 24.05.2013 17:52, Robin Rosenberg wrote:
> Stefan Lay skrev 2013-05-23 17.58:
>> I don't yet know why the second test fails, but I can make it work if
>> I change the assert to
>> boolean merged = rw.isMergedInto(rw.lookupCommit(master),
>> rw.lookupCommit(extra));
>>
>> Somehow the revwalk does not correctly walk the topology.
>
> I think it is this: Here, and in general, when a method accepts a
> RevObject of some kind,
> (and possibly a RevWalk) it means all objects must be allocated by the
> same RevWalk instance.
> The javadoc should mention this.
>
> -- robin
>
Previous Topic:http.sslcainfo config option
Next Topic:add content without file
Goto Forum:
  


Current Time: Sat Aug 23 15:52:56 EDT 2014

Powered by FUDForum. Page generated in 0.01787 seconds