summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgidijus Vaisnora2012-01-11 02:56:14 (EST)
committerEgidijus Vaisnora2012-01-11 02:56:14 (EST)
commit295dfedecf851334f409530b935eea610cd9d0a4 (patch)
tree2429568a0490a0ef030c641487691a0170fa94d6
parent2800e0660f5343c592c76281b969c85b4bafc087 (diff)
downloadcdo-295dfedecf851334f409530b935eea610cd9d0a4.zip
cdo-295dfedecf851334f409530b935eea610cd9d0a4.tar.gz
cdo-295dfedecf851334f409530b935eea610cd9d0a4.tar.bz2
Fixed MergingTest.testFromBranchRemovalInSource
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java23
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java21
2 files changed, 31 insertions, 13 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
index ae6aaa4..4aeccd6 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
@@ -981,10 +981,6 @@ public class TransactionCommitContext implements InternalCommitContext
CDOID id = delta.getID();
InternalCDORevision oldRevision = revisionManager.getRevisionByVersion(id, delta, CDORevision.UNCHUNKED, true);
- if (oldRevision == null)
- {
- throw new IllegalStateException("Origin revision not found for " + delta);
- }
CDOBranch branch = transaction.getBranch();
checkForStaleRevision(oldRevision, branch);
@@ -1007,6 +1003,11 @@ public class TransactionCommitContext implements InternalCommitContext
private void checkForStaleRevision(InternalCDORevision oldRevision, CDOBranch branch)
{
+ if (oldRevision == null)
+ {
+ throw new IllegalStateException("Origin revision not found for " + oldRevision);
+ }
+
if (ObjectUtil.equals(oldRevision.getBranch(), branch) && oldRevision.isHistorical())
{
throw new ConcurrentModificationException("Attempt by " + transaction + " to modify historical revision: "
@@ -1230,15 +1231,13 @@ public class TransactionCommitContext implements InternalCommitContext
{
CDOID id = detachedObjects[i].getID();
CDOBranch branch = transaction.getBranch();
- InternalCDORevision oldRevision = revisionManager.getRevisionByVersion(id,
- branch.getVersion(detachedObjects[i].getVersion()), CDORevision.UNCHUNKED, true);
-
- /*
- * why oldRevision is null, even if it is present in the revision cache? Because it is PointerCDORevision and
- * it's method getVersion gives UNSPECIFIED_VERSION
- */
- if (oldRevision != null)
+ // if we are removing object which has no version in a branch, his version will be UNSPECIFIED_VERSION. We do
+ // not need to check it
+ if (detachedObjects[i].getVersion() != CDORevision.UNSPECIFIED_VERSION)
{
+ InternalCDORevision oldRevision = revisionManager.getRevisionByVersion(id,
+ branch.getVersion(detachedObjects[i].getVersion()), CDORevision.UNCHUNKED, true);
+
checkForStaleRevision(oldRevision, branch);
}
// Remember the cached revision that must be revised after successful commit through updateInfraStructure
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
index e628aab..ba21517 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
@@ -2543,12 +2543,31 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
detachedObjects = filterCommittables(transaction.getDetachedObjects());
+ boolean supportingBranches = transaction.getSession().getRepositoryInfo().isSupportingBranches();
List<CDOIDAndVersion> detached = new ArrayList<CDOIDAndVersion>(detachedObjects.size());
for (CDOID id : detachedObjects.keySet())
{
// Add "version-less" key.
// CDOSessionImpl.reviseRevisions() will call reviseLatest() accordingly.
- detached.add(CDOIDUtil.createIDAndVersion(id, getCleanRevisions().get(detachedObjects.get(id)).getVersion()));
+ InternalCDORevision detachedRevision = getCleanRevisions().get(detachedObjects.get(id));
+
+ if (supportingBranches)
+ {
+ if (detachedRevision.getBranch().equals(getBranch()))
+ {
+ detached.add(CDOIDUtil.createIDAndVersion(id, detachedRevision.getVersion()));
+ }
+ else
+ {
+ // Branch for clean revision do not match to branch in which it was deleted. This can only happen
+ // when in current branch there was no version created
+ detached.add(CDOIDUtil.createIDAndVersion(id, CDORevision.UNSPECIFIED_VERSION));
+ }
+ }
+ else
+ {
+ detached.add(CDOIDUtil.createIDAndVersion(id, detachedRevision.getVersion()));
+ }
}
dirtyObjects = filterCommittables(transaction.getDirtyObjects());