Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-10-11 15:39:08 +0000
committerEike Stepper2010-10-11 15:39:08 +0000
commit3edad2dccea3d5cc020b5dfeb28fdf18b54b64bf (patch)
tree4feea820600c7a70b6c81b2b9f2ee892c199c11b /plugins/org.eclipse.emf.cdo.workspace
parent229dd2d535ca38d72fd79f637d5eb2f2e47e3426 (diff)
downloadcdo-3edad2dccea3d5cc020b5dfeb28fdf18b54b64bf.tar.gz
cdo-3edad2dccea3d5cc020b5dfeb28fdf18b54b64bf.tar.xz
cdo-3edad2dccea3d5cc020b5dfeb28fdf18b54b64bf.zip
[327405] Provide an offline CDOWorkspace with Checkout/Update/Commit workflows
https://bugs.eclipse.org/bugs/show_bug.cgi?id=327405
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.workspace')
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java
index 90e39883f5..616fdaacc7 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java
@@ -12,6 +12,8 @@ package org.eclipse.emf.cdo.internal.workspace;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSet;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.id.CDOID;
@@ -29,6 +31,7 @@ import org.eclipse.emf.cdo.server.StoreThreadLocal;
import org.eclipse.emf.cdo.server.net4j.CDONet4jServerUtil;
import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
+import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
@@ -222,8 +225,35 @@ public class CDOWorkspaceImpl implements CDOWorkspace
public CDOTransaction update(CDOMerger merger, String branchPath, long timeStamp)
{
- // TODO: implement CDOWorkspaceImpl.update(merger, branchPath, timeStamp)
- throw new UnsupportedOperationException();
+ InternalCDOSession session = openRemoteSession();
+
+ try
+ {
+ InternalCDOBranchManager branchManager = session.getBranchManager();
+ CDOBranchPoint base = branchManager.getBranch(baseline.getBranchPath()).getPoint(baseline.getTimeStamp());
+ CDOBranchPoint remote = branchManager.getBranch(branchPath).getPoint(timeStamp);
+ CDOBranchPoint local = branchManager.getBranch(branchPath).getPoint(timeStamp);
+
+ CDOBranchPointRange range = CDOBranchUtil.createRange(base, remote);
+ CDOChangeSetData remoteData = session.getSessionProtocol().loadChangeSets(range)[0];
+ CDOChangeSetData localData = getLocalChanges();
+
+ CDOChangeSet localChanges = CDORevisionDeltaUtil.createChangeSet(base, local, localData);
+ CDOChangeSet remoteChanges = CDORevisionDeltaUtil.createChangeSet(base, remote, remoteData);
+ CDOChangeSetData result = merger.merge(localChanges, remoteChanges);
+
+ InternalCDOTransaction transaction = (InternalCDOTransaction)openTransaction();
+ transaction.applyChangeSetData(result, baseline, this, null);
+
+ baseline.clear();
+ baseline.setLastUpdateTime(timeStamp);
+
+ return transaction;
+ }
+ finally
+ {
+ LifecycleUtil.deactivate(session);
+ }
}
public void revert()

Back to the top