JGit RevWalk.isMergedInto() [message #1058575] |
Tue, 14 May 2013 09:42  |
Eclipse User |
|
|
|
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 #1060959 is a reply to message #1060437] |
Wed, 29 May 2013 06:12  |
Eclipse User |
|
|
|
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
>
|
|
|
Powered by
FUDForum. Page generated in 1.06642 seconds