Author: baedke
Date: Tue Sep 27 13:01:29 2016
New Revision: 1762473
URL: http://svn.apache.org/viewvc?rev=1762473&view=rev
Log:
OAK-4556: Track branch on newBranchCommit()
Modified:
jackrabbit/oak/branches/1.4/ (props changed)
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MergeCommit.java
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Propchange: jackrabbit/oak/branches/1.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 27 13:01:29 2016
@@ -1,3 +1,3 @@
/jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1733615,1733875,1733913,1733929,1734230,1734254,1734279,1734941,1735052,1735081,1735141,1735267,1735405,1735484,1735549,1735564,1735588,1735622,1735638,1735919,1735983,1736176,1737309-1737310,1737334,1737349,1737998,1738004,1738136,1738138,1738207,1738234,1738252,1738775,1738795,1738833,1738950,1738957,1738963,1739712,1739760,1739867,1739894,1739959-1739960,1740114,1740116,1740250,1740333,1740360,1740625-1740626,1740774,1740837,1740971,1741016,1741032,1741339,1741343,1742077,1742117,1742363,1742520,1742888,1742916,1743097,1743172,1743343,1743674,1744265,1744292,1744589,1744670,1744672,1744959,1745038,1745127,1745197,1745336,1745368,1746086,1746117,1746342,1746345,1746408,1746696,1746981,1747198,1747200,1747341-1747342,1747380,1747387,1747406,1747492,1747512,1747654,1748505,1748553,1748722,1748870,1749275,1749350,1749424,1749443,1749464,1749475,1749645,1749662,1749815,1749872,1749875,1749899,1750052,1750076-1750077,1750287,1750457,1750462,1750465,1750495,1750626
,1750809,1750886,1751410,1751445-1751446,1751478,1751755,1751871,1752198,1752202,1752259,1752273-1752274,1752283,1752292,1752438,1752447,1752508,1752616,1752659,1752672,1753262,1753331-1753332,1753355,1753444,1754117,1754239,1755157,1756520,1756580,1757119,1757166,1759433,1760340,1760373,1760387,1760661-1760662,1761412,1761444,1761571,1761762,1761787
+/jackrabbit/oak/trunk:1733615,1733875,1733913,1733929,1734230,1734254,1734279,1734941,1735052,1735081,1735141,1735267,1735405,1735484,1735549,1735564,1735588,1735622,1735638,1735919,1735983,1736176,1737309-1737310,1737334,1737349,1737998,1738004,1738136,1738138,1738207,1738234,1738252,1738775,1738795,1738833,1738950,1738957,1738963,1739712,1739760,1739867,1739894,1739959-1739960,1740114,1740116,1740250,1740333,1740360,1740625-1740626,1740774,1740837,1740971,1741016,1741032,1741339,1741343,1742077,1742117,1742363,1742520,1742888,1742916,1743097,1743172,1743343,1743674,1744265,1744292,1744589,1744670,1744672,1744959,1745038,1745127,1745197,1745336,1745368,1746086,1746117,1746342,1746345,1746408,1746696,1746981,1747198,1747200,1747341-1747342,1747380,1747387,1747406,1747492,1747512,1747654,1748505,1748553,1748722,1748870,1749275,1749350,1749424,1749443,1749464,1749475,1749645,1749662,1749815,1749872,1749875,1749899,1750052,1750076-1750077,1750287,1750457,1750462,1750465,1750495,1750626
,1750809,1750886,1751410,1751445-1751446,1751478,1751755,1751871,1752198,1752202,1752259,1752273-1752274,1752283,1752292,1752438,1752447-1752448,1752508,1752616,1752659,1752672,1753262,1753331-1753332,1753355,1753444,1754117,1754239,1755157,1756520,1756580,1757119,1757166,1759433,1760340,1760373,1760387,1760661-1760662,1761412,1761444,1761571,1761762,1761787
/jackrabbit/trunk:1345480
Modified:
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java?rev=1762473&r1=1762472&r2=1762473&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
(original)
+++
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
Tue Sep 27 13:01:29 2016
@@ -61,7 +61,6 @@ public class Commit {
private static final Logger LOG = LoggerFactory.getLogger(Commit.class);
protected final DocumentNodeStore nodeStore;
- private final DocumentNodeStoreBranch branch;
private final RevisionVector baseRevision;
private final Revision revision;
private final HashMap<String, UpdateOp> operations = new
LinkedHashMap<String, UpdateOp>();
@@ -88,18 +87,13 @@ public class Commit {
* @param revision the revision for this commit.
* @param baseRevision the base revision for this commit or {@code null} if
* there is none.
- * @param branch the branch associated with this commit or {@code null} if
- * there is none.
- *
*/
Commit(@Nonnull DocumentNodeStore nodeStore,
@Nonnull Revision revision,
- @Nullable RevisionVector baseRevision,
- @Nullable DocumentNodeStoreBranch branch) {
+ @Nullable RevisionVector baseRevision) {
this.nodeStore = checkNotNull(nodeStore);
this.revision = checkNotNull(revision);
this.baseRevision = baseRevision;
- this.branch = branch;
}
UpdateOp getUpdateOperationForNode(String path) {
@@ -190,28 +184,13 @@ public class Commit {
boolean isBranch = baseRev != null && baseRev.isBranch();
Revision rev = getRevision();
if (isBranch && !nodeStore.isDisableBranches()) {
- rev = rev.asBranchRevision();
- // remember branch commit
- Branch b = nodeStore.getBranches().getBranch(baseRev);
- if (b == null) {
- // baseRev is marker for new branch
- b = nodeStore.getBranches().create(
- baseRev.asTrunkRevision(), rev, branch);
- LOG.debug("Branch created with base revision {} and " +
- "modifications on {}", baseRevision,
operations.keySet());
- if (LOG.isTraceEnabled()) {
- LOG.trace("Branch created", new Exception());
- }
- } else {
- b.addCommit(rev);
- }
try {
// prepare commit
prepare(baseRev);
success = true;
} finally {
if (!success) {
- b.removeCommit(rev);
+ b.removeCommit(rev.asBranchRevision());
if (!b.hasCommits()) {
nodeStore.getBranches().remove(b);
}
Modified:
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java?rev=1762473&r1=1762472&r2=1762473&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
(original)
+++
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
Tue Sep 27 13:01:29 2016
@@ -450,7 +450,7 @@ public final class DocumentNodeStore
if (rootDoc == null) {
// root node is missing: repository is not initialized
Revision commitRev = newRevision();
- Commit commit = new Commit(this, commitRev, null, null);
+ Commit commit = new Commit(this, commitRev, null);
RevisionVector head = new RevisionVector(commitRev);
DocumentNodeState n = new DocumentNodeState(this, "/", head);
commit.addNode(n);
@@ -695,6 +695,11 @@ public final class DocumentNodeStore
} finally {
backgroundOperationLock.readLock().unlock();
}
+ } else {
+ Branch b = branches.getBranch(c.getBaseRevision());
+ if (b != null) {
+ b.removeCommit(c.getRevision().asBranchRevision());
+ }
}
}
@@ -2111,7 +2116,7 @@ public final class DocumentNodeStore
Commit c;
try {
checkOpen();
- c = new Commit(this, commitQueue.createRevision(), base, null);
+ c = new Commit(this, commitQueue.createRevision(), base);
success = true;
} finally {
if (!success) {
@@ -2128,7 +2133,23 @@ public final class DocumentNodeStore
"base must be a branch revision: " + base);
checkOpen();
- return new Commit(this, newRevision(), base, branch);
+ Commit c = new Commit(this, newRevision(), base);
+ if (!isDisableBranches()) {
+ Revision rev = c.getRevision().asBranchRevision();
+ // remember branch commit
+ Branch b = getBranches().getBranch(base);
+ if (b == null) {
+ // baseRev is marker for new branch
+ getBranches().create(base.asTrunkRevision(), rev, branch);
+ LOG.debug("Branch created with base revision {}", base);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Branch created", new Exception());
+ }
+ } else {
+ b.addCommit(rev);
+ }
+ }
+ return c;
}
/**
Modified:
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MergeCommit.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MergeCommit.java?rev=1762473&r1=1762472&r2=1762473&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MergeCommit.java
(original)
+++
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MergeCommit.java
Tue Sep 27 13:01:29 2016
@@ -35,7 +35,7 @@ class MergeCommit extends Commit {
MergeCommit(DocumentNodeStore nodeStore,
RevisionVector baseRevision,
SortedSet<Revision> revisions) {
- super(nodeStore, revisions.last(), baseRevision, null);
+ super(nodeStore, revisions.last(), baseRevision);
this.mergeRevs = revisions;
}
Modified:
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java?rev=1762473&r1=1762472&r2=1762473&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java
(original)
+++
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/UnsavedModifications.java
Tue Sep 27 13:01:29 2016
@@ -179,7 +179,7 @@ class UnsavedModifications {
int size = pathList.size();
if (updateOp == null) {
// create UpdateOp
- Commit commit = new Commit(store, r, null, null);
+ Commit commit = new Commit(store, r, null);
updateOp = commit.getUpdateOperationForNode(p);
NodeDocument.setLastRev(updateOp, r);
lastRev = r;
Modified:
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java?rev=1762473&r1=1762472&r2=1762473&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
(original)
+++
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Tue Sep 27 13:01:29 2016
@@ -271,7 +271,7 @@ public class DocumentNodeStoreTest {
public void run() {
try {
Revision r = store.newRevision();
- Commit c = new Commit(store, r, head, null);
+ Commit c = new Commit(store, r, head);
c.addNode(new DocumentNodeState(store,
"/newConflictingNode", new RevisionVector(r)));
c.addNode(new DocumentNodeState(store, "/deletedNode", new
RevisionVector(r)));
c.updateProperty("/updateNode", "foo", "baz");
@@ -289,7 +289,7 @@ public class DocumentNodeStoreTest {
created.acquireUninterruptibly();
// commit will succeed and add collision marker to writer commit
Revision r = store.newRevision();
- Commit c = new Commit(store, r, head, null);
+ Commit c = new Commit(store, r, head);
c.addNode(new DocumentNodeState(store, "/newConflictingNode", new
RevisionVector(r)));
c.addNode(new DocumentNodeState(store, "/newNonConflictingNode", new
RevisionVector(r)));
c.apply();