Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] multiple merge between branches(Can;t get multiple merge between branches to work)
[CDO] multiple merge between branches [message #998790] Thu, 10 January 2013 17:54 Go to next message
Lothar Werzinger is currently offline Lothar WerzingerFriend
Messages: 153
Registered: July 2009
Location: Bay Area
Senior Member
I am trying to implement a workflow feature where changes are made in one branch (draft) first and then later are promoted to another branch (release).

The code below is trying to use that paradigm.
I tried both merge methods of the CDOTransaction (with and without sourcebase), but I can not make any of them work. The version without sourcebase (testRemerge2) fails because after the merge the contents are not merged:
Quote:

junit.framework.AssertionFailedError: expected:<5> but was:<0>

and the version with sourcebase (testRemerge) fails with an exception during merge:
Quote:

org.eclipse.emf.cdo.tests.config.impl.ConfigTestException: Error in BranchMergeTest.testRemerge [Combined, H2-branching-ranges, JVM, Native]
at org.eclipse.emf.cdo.tests.config.impl.ConfigTest.runBare(ConfigTest.java:562)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at org.eclipse.net4j.util.tests.AbstractOMTest.run(AbstractOMTest.java:264)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.IllegalArgumentException: Source base is not contained in BranchPoint[Branch[id=1, name=draft], 2013-01-10 09:44:01.315]
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.merge(CDOTransactionImpl.java:466)
at biz.tradescape.mmt.tests.cdo.BranchMergeTest.testRemerge(BranchMergeTest.java:126)
...


Any help is highly appreciated.

Thanks!

Lothar


  public void testRemerge() throws Exception
  {
    CDOSession session = openSession();
    CDOBranch mainBranch = session.getBranchManager().getMainBranch();
    
    CDOTransaction transaction = session.openTransaction(mainBranch);
    CDOResource resource = transaction.createResource(getResourcePath("/res"));
    long timeCreate = transaction.commit().getTimeStamp();
    
    CDOBranch draft = mainBranch.createBranch("draft", timeCreate);
    CDOBranch release = mainBranch.createBranch("release", timeCreate);
    
    CDOTransaction tx0 = session.openTransaction(draft);
    CDOResource res0 = tx0.getResource(getResourcePath("/res"));
    EList<EObject> contents0 = resource.getContents();
    Company company0 = addCompany(contents0);
    Company company1 = addCompany(contents0);
    Company company2 = addCompany(contents0);
    Company company3 = addCompany(contents0);
    Company company4 = addCompany(contents0);
    long timeModify = tx0.commit().getTimeStamp();
    
    sleep(10);
    
    CDOTransaction tx1 = session.openTransaction(release);
    CDOResource res1 = tx1.getResource(getResourcePath("/res"));
    EList<EObject> contents1 = res1.getContents();
    assertEquals(0, contents1.size());
    tx1.merge(
      draft.getHead(), draft.getPoint(timeCreate),
      new DefaultCDOMerger.PerFeature.ManyValued());
    tx1.commit();
    assertEquals(5, contents1.size());
    
    Company company5 = addCompany(contents0);
    Company company6 = addCompany(contents0);
    transaction.commit();
    
    sleep(10);
    
    CDOChangeSetData result =
      tx1.merge(
        draft.getHead(), draft.getPoint(timeModify),
        new DefaultCDOMerger.PerFeature.ManyValued());
    assertEquals(true, result.isEmpty());
    assertEquals(false, tx1.isDirty());
    
    session.close();
  }

  public void testRemerge2() throws Exception
  {
    CDOSession session = openSession();
    CDOBranch mainBranch = session.getBranchManager().getMainBranch();
    
    CDOTransaction transaction = session.openTransaction(mainBranch);
    CDOResource resource = transaction.createResource(getResourcePath("/res"));
    long timeCreate = transaction.commit().getTimeStamp();
    
    CDOBranch draft = mainBranch.createBranch("draft", timeCreate);
    CDOBranch release = mainBranch.createBranch("release", timeCreate);
    
    CDOTransaction tx0 = session.openTransaction(draft);
    CDOResource res0 = tx0.getResource(getResourcePath("/res"));
    EList<EObject> contents0 = resource.getContents();
    Company company0 = addCompany(contents0);
    Company company1 = addCompany(contents0);
    Company company2 = addCompany(contents0);
    Company company3 = addCompany(contents0);
    Company company4 = addCompany(contents0);
    long timeModify = tx0.commit().getTimeStamp();
    
    sleep(10);
    
    CDOTransaction tx1 = session.openTransaction(release);
    CDOResource res1 = tx1.getResource(getResourcePath("/res"));
    EList<EObject> contents1 = res1.getContents();
    assertEquals(0, contents1.size());
    tx1.merge(draft.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
    tx1.commit();
    assertEquals(5, contents1.size());
    
    Company company5 = addCompany(contents0);
    Company company6 = addCompany(contents0);
    transaction.commit();
    
    sleep(10);
    
    CDOChangeSetData result =
      tx1.merge(
        draft.getHead(), draft.getPoint(timeModify),
        new DefaultCDOMerger.PerFeature.ManyValued());
    assertEquals(true, result.isEmpty());
    assertEquals(false, tx1.isDirty());
    
    session.close();
  }
Re: [CDO] multiple merge between branches [message #999044 is a reply to message #998790] Fri, 11 January 2013 08:08 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 10.01.2013 18:54, schrieb Lothar Werzinger:
> I am trying to implement a workflow feature where changes are made in one branch (draft) first and then later are
> promoted to another branch (release).
>
> The code below is trying to use that paradigm.
> I tried both merge methods of the CDOTransaction (with and without sourcebase), but I can not make any of them work.
> The version without sourcebase (testRemerge2) fails because after the merge the contents are not merged:
> Quote:
>> junit.framework.AssertionFailedError: expected:<5> but was:<0>
Yes, that method is not meant to be able to *re* -merge from a branch.

> and the version with sourcebase (testRemerge) fails with an exception during merge:
> Quote:
>> org.eclipse.emf.cdo.tests.config.impl.ConfigTestException: Error in BranchMergeTest.testRemerge [Combined,
>> H2-branching-ranges, JVM, Native]
>> at org.eclipse.emf.cdo.tests.config.impl.ConfigTest.runBare(ConfigTest.java:562)
>> at junit.framework.TestResult$1.protect(TestResult.java:110)
>> at junit.framework.TestResult.runProtected(TestResult.java:128)
>> at junit.framework.TestResult.run(TestResult.java:113)
>> at junit.framework.TestCase.run(TestCase.java:124)
>> at org.eclipse.net4j.util.tests.AbstractOMTest.run(AbstractOMTest.java:264)
>> at junit.framework.TestSuite.runTest(TestSuite.java:243)
>> at junit.framework.TestSuite.run(TestSuite.java:238)
>> at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
>> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
>> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>> Caused by: java.lang.IllegalArgumentException: Source base is not contained in BranchPoint[Branch[id=1, name=draft],
>> 2013-01-10 09:44:01.315]
It seems that this is a minor bug (missing "!" in front of "isContainedBy()"). Please submit a bugzilla.

>> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.merge(CDOTransactionImpl.java:466)
>> at biz.tradescape.mmt.tests.cdo.BranchMergeTest.testRemerge(BranchMergeTest.java:126)
>> ...
>
>
> Any help is highly appreciated.
Unfortunately I found out that the re-merge method is conceptually broken ;-(

Explanation:

The first version of the CDOTransaction.merge() method expected one parameter, the source branchpoint. The target point
is always implicitly the head of the current transaction and the common ancestor was automatically calculated from the
persistent branch tree. (3 points involved).

Later it became obvious that remerging from the same source branch requires an additional point: the "source base",
which is the last commit in the source branch that has already been merged. Unfortunately I made the wrong assumption
that the "target base" still is the common ancestor, ignoring that former merges have already considered the changes in
the target branch between the ancestor and the head (== implicit target). An explicit "target base" parameter is missing
in the APIs and in the network protocol.

There are two options:

a) Offer a third merge() method with the missing parameter.

b) Make CDO remember what merges have already taken place, so that only the first simple merge method is ever needed.
This is clearly the superior solution as it is way more convenient for users (they'd no longer need to remember their
merge points externally). Unfortunately (and we've discussed that twice already) this is not a trivial effort because
many APIs and the IStore implementations would be affected.

I hope I could make the problem and possible solutions clear.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] multiple merge between branches [message #999289 is a reply to message #999044] Fri, 11 January 2013 18:31 Go to previous message
Lothar Werzinger is currently offline Lothar WerzingerFriend
Messages: 153
Registered: July 2009
Location: Bay Area
Senior Member
Bug 397999 created: https://bugs.eclipse.org/bugs/show_bug.cgi?id=397999
Previous Topic:Using EMF.Edit with a JFace tree viewer
Next Topic:Loading Resource from EMF generated Plugin
Goto Forum:
  


Current Time: Fri Mar 29 05:04:36 GMT 2024

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

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

Back to the top