Fixed MergingTest.testFromBranchRemovalInSource
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 @@
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 @@
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 @@
{
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 @@
}
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());