Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » JGit RevWalk.isMergedInto()
JGit RevWalk.isMergedInto() [message #1058575] Tue, 14 May 2013 13:42 Go to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
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 15:58 Go to previous messageGo to next message
Stefan Lay is currently offline Stefan LayFriend
Messages: 342
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 15:52 Go to previous messageGo to next message
Robin Rosenberg is currently offline Robin RosenbergFriend
Messages: 332
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 09:27 Go to previous messageGo to next message
Stefan Lay is currently offline Stefan LayFriend
Messages: 342
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 10:12 Go to previous message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
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:Egit will not install on Juno
Next Topic:add content without file
Goto Forum:
  


Current Time: Tue Apr 16 20:12:12 GMT 2024

Powered by FUDForum. Page generated in 1.97040 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top