couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1086242 - in /couchdb/branches/1.0.x: share/www/script/test/purge.js src/couchdb/couch_db_updater.erl
Date Mon, 28 Mar 2011 14:02:06 GMT
Author: jan
Date: Mon Mar 28 14:02:06 2011
New Revision: 1086242

URL: http://svn.apache.org/viewvc?rev=1086242&view=rev
Log:
Fix function signature mismatch. Allow purging of single revisions in a conflicted
document.

Closes COUCHDB-1065

Patch by Randall Leeds, verified by Robert Dionne.

Modified:
    couchdb/branches/1.0.x/share/www/script/test/purge.js
    couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl

Modified: couchdb/branches/1.0.x/share/www/script/test/purge.js
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/www/script/test/purge.js?rev=1086242&r1=1086241&r2=1086242&view=diff
==============================================================================
--- couchdb/branches/1.0.x/share/www/script/test/purge.js (original)
+++ couchdb/branches/1.0.x/share/www/script/test/purge.js Mon Mar 28 14:02:06 2011
@@ -110,4 +110,36 @@ couchTests.purge = function(debug) {
     T(rows[(2*(i-4))+1].key == i+1);
   }
   T(db.view("test/single_doc").total_rows == 0);
+
+  // COUCHDB-1065
+  var dbA = new CouchDB("test_suite_db_a");
+  var dbB = new CouchDB("test_suite_db_b");
+  dbA.deleteDb();
+  dbA.createDb();
+  dbB.deleteDb();
+  dbB.createDb();
+  var docA = {_id:"test", a:1};
+  var docB = {_id:"test", a:2};
+  dbA.save(docA);
+  dbB.save(docB);
+  CouchDB.replicate(dbA.name, dbB.name);
+  var xhr = CouchDB.request("POST", "/" + dbB.name + "/_purge", {
+    body: JSON.stringify({"test":[docA._rev]})
+  });
+  TEquals(200, xhr.status, "single rev purge after replication succeeds");
+
+  var xhr = CouchDB.request("GET", "/" + dbB.name + "/test?rev=" + docA._rev);
+  TEquals(404, xhr.status, "single rev purge removes revision");
+
+  var xhr = CouchDB.request("POST", "/" + dbB.name + "/_purge", {
+    body: JSON.stringify({"test":[docB._rev]})
+  });
+  TEquals(200, xhr.status, "single rev purge after replication succeeds");
+  var xhr = CouchDB.request("GET", "/" + dbB.name + "/test?rev=" + docB._rev);
+  TEquals(404, xhr.status, "single rev purge removes revision");
+
+  var xhr = CouchDB.request("POST", "/" + dbB.name + "/_purge", {
+    body: JSON.stringify({"test":[docA._rev, docB._rev]})
+  });
+  TEquals(200, xhr.status, "all rev purge after replication succeeds");
 };

Modified: couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl?rev=1086242&r1=1086241&r2=1086242&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl Mon Mar 28 14:02:06 2011
@@ -118,8 +118,9 @@ handle_call({purge_docs, IdRevs}, _From,
 
     {DocInfoToUpdate, NewSeq} = lists:mapfoldl(
         fun(#full_doc_info{rev_tree=Tree}=FullInfo, SeqAcc) ->
-            Tree2 = couch_key_tree:map_leafs( fun(RevInfo) ->
-                    RevInfo#rev_info{seq=SeqAcc + 1}
+            Tree2 = couch_key_tree:map_leafs(
+                fun(_RevId, {IsDeleted, BodyPointer, _UpdateSeq}) ->
+                    {IsDeleted, BodyPointer, SeqAcc + 1}
                 end, Tree),
             {couch_doc:to_doc_info(FullInfo#full_doc_info{rev_tree=Tree2}),
                 SeqAcc + 1}



Mime
View raw message