jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r1298471 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk: Repository.java model/CommitBuilder.java
Date Thu, 08 Mar 2012 17:09:05 GMT
Author: dpfister
Date: Thu Mar  8 17:09:05 2012
New Revision: 1298471

URL: http://svn.apache.org/viewvc?rev=1298471&view=rev
Log:
refactor String commit id's in Id instances

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/Repository.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/Repository.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/Repository.java?rev=1298471&r1=1298470&r2=1298471&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/Repository.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/Repository.java Thu
Mar  8 17:09:05 2012
@@ -166,7 +166,6 @@ public class Repository {
 
     public CommitBuilder getCommitBuilder(String revId, String msg) throws Exception {
         return new CommitBuilder(revId, msg, rs);
-
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java?rev=1298471&r1=1298470&r2=1298471&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
Thu Mar  8 17:09:05 2012
@@ -33,22 +33,21 @@ import java.util.Map;
  */
 public class CommitBuilder {
 
-    String baseRevId;
+    private Id baseRevId;
 
-    final String msg;
+    private final String msg;
 
-    final RevisionStore store;
+    private final RevisionStore store;
 
-    final Map<String, MutableNode> staged;
+    // key is a path
+    private final Map<String, MutableNode> staged = new HashMap<String, MutableNode>();
     // change log
-    final List<Change> changeLog;
+    private final List<Change> changeLog = new ArrayList<Change>();
 
     public CommitBuilder(String baseRevId, String msg, RevisionStore store) throws Exception
{
-        this.baseRevId = baseRevId;
+        this.baseRevId = Id.fromString(baseRevId);
         this.msg = msg;
         this.store = store;
-        staged = new HashMap<String, MutableNode>();
-        changeLog = new ArrayList<Change>();
     }
 
     public void addNode(String parentNodePath, String nodeName) throws Exception {
@@ -173,10 +172,10 @@ public class CommitBuilder {
     public String /* new revId */ doCommit() throws Exception {
         if (staged.isEmpty()) {
             // nothing to commit
-            return baseRevId;
+            return baseRevId.toString();
         }
 
-        String currentHead = store.getHeadCommitId().toString();
+        Id currentHead = store.getHeadCommitId();
         if (!currentHead.equals(baseRevId)) {
             // todo gracefully handle certain conflicts (e.g. changes on moved sub-trees,
competing deletes etc)
             // update base revision to new head
@@ -196,10 +195,10 @@ public class CommitBuilder {
         Id newRevId;
         store.lockHead();
         try {
-            currentHead = store.getHeadCommitId().toString();
+            currentHead = store.getHeadCommitId();
             if (!currentHead.equals(baseRevId)) {
-                StoredNode baseRoot = store.getRootNode(Id.fromString(baseRevId));
-                StoredNode theirRoot = store.getRootNode(Id.fromString(currentHead));
+                StoredNode baseRoot = store.getRootNode(baseRevId);
+                StoredNode theirRoot = store.getRootNode(currentHead);
                 StoredNode ourRoot = store.getNode(rootNodeId);
 
                 rootNodeId = mergeTree(baseRoot, ourRoot, theirRoot);
@@ -207,13 +206,13 @@ public class CommitBuilder {
                 baseRevId = currentHead;
             }
 
-            if (store.getCommit(Id.fromString(currentHead)).getRootNodeId().equals(rootNodeId))
{
+            if (store.getCommit(currentHead).getRootNodeId().equals(rootNodeId)) {
                 // the commit didn't cause any changes,
                 // no need to create new commit object/update head revision
-                return currentHead;
+                return currentHead.toString();
             }
             MutableCommit newCommit = new MutableCommit();
-            newCommit.setParentId(Id.fromString(baseRevId));
+            newCommit.setParentId(baseRevId);
             newCommit.setCommitTS(System.currentTimeMillis());
             newCommit.setMsg(msg);
             newCommit.setRootNodeId(rootNodeId);
@@ -236,7 +235,7 @@ public class CommitBuilder {
         if (node == null) {
             MutableNode parent = staged.get("/");
             if (parent == null) {
-                parent = new MutableNode(store.getRootNode(Id.fromString(baseRevId)), store);
+                parent = new MutableNode(store.getRootNode(baseRevId), store);
                 staged.put("/", parent);
             }
             node = parent;



Mime
View raw message