You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by fd...@apache.org on 2010/09/22 17:15:16 UTC

svn commit: r1000032 - in /couchdb/branches/new_replicator: share/www/script/test/new_replication.js src/couchdb/couch_replicate.erl

Author: fdmanana
Date: Wed Sep 22 15:15:16 2010
New Revision: 1000032

URL: http://svn.apache.org/viewvc?rev=1000032&view=rev
Log:
New replicator: allow percent encoded doc IDs just like the "old" replicator.

Modified:
    couchdb/branches/new_replicator/share/www/script/test/new_replication.js
    couchdb/branches/new_replicator/src/couchdb/couch_replicate.erl

Modified: couchdb/branches/new_replicator/share/www/script/test/new_replication.js
URL: http://svn.apache.org/viewvc/couchdb/branches/new_replicator/share/www/script/test/new_replication.js?rev=1000032&r1=1000031&r2=1000032&view=diff
==============================================================================
--- couchdb/branches/new_replicator/share/www/script/test/new_replication.js (original)
+++ couchdb/branches/new_replicator/share/www/script/test/new_replication.js Wed Sep 22 15:15:16 2010
@@ -541,6 +541,7 @@ couchTests.new_replication = function(de
     { initial: ["1", "2"], after: ["7"], conflict_id: "1" },
     { initial: ["1", "foo_666", "10"], after: ["7"], conflict_id: "10" },
     { initial: ["_design/foo", "8"], after: ["foo_5"], conflict_id: "8" },
+    { initial: ["_design%2Ffoo", "8"], after: ["foo_5"], conflict_id: "8" },
     { initial: [], after: ["foo_1000", "_design/foo", "1"], conflict_id: "1" }
   ];
   var doc_ids, after_doc_ids;
@@ -582,7 +583,7 @@ couchTests.new_replication = function(de
       T(repResult.doc_write_failures === 0);
 
       for (k = 0; k < doc_ids.length; k++) {
-        id = doc_ids[k];
+        id = decodeURIComponent(doc_ids[k]);
         doc = sourceDb.open(id);
         copy = targetDb.open(id);
 
@@ -598,10 +599,11 @@ couchTests.new_replication = function(de
 
       // be absolutely sure that other docs were not replicated
       for (k = 0; k < docs.length; k++) {
-        id = docs[k]._id;
-        doc = targetDb.open(id);
+        var base_id = docs[k]._id;
+        id = encodeURIComponent(base_id);
+        doc = targetDb.open(base_id);
 
-        if (doc_ids.indexOf(id) >= 0) {
+        if ((doc_ids.indexOf(id) >= 0) || (doc_ids.indexOf(base_id) >= 0)) {
             T(doc !== null);
         } else {
             T(doc === null);
@@ -658,10 +660,13 @@ couchTests.new_replication = function(de
 
       // be absolutely sure that other docs were not replicated
       for (k = 0; k < docs.length; k++) {
-        id = docs[k]._id;
-        doc = targetDb.open(id);
-
-        if ((doc_ids.indexOf(id) >= 0) || (after_doc_ids.indexOf(id) >= 0)) {
+        var base_id = docs[k]._id;
+        id = encodeURIComponent(base_id);
+        doc = targetDb.open(base_id);
+
+        if ((doc_ids.indexOf(id) >= 0) || (after_doc_ids.indexOf(id) >= 0) ||
+            (doc_ids.indexOf(base_id) >= 0) ||
+            (after_doc_ids.indexOf(base_id) >= 0)) {
             T(doc !== null);
         } else {
             T(doc === null);

Modified: couchdb/branches/new_replicator/src/couchdb/couch_replicate.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/new_replicator/src/couchdb/couch_replicate.erl?rev=1000032&r1=1000031&r2=1000032&view=diff
==============================================================================
--- couchdb/branches/new_replicator/src/couchdb/couch_replicate.erl (original)
+++ couchdb/branches/new_replicator/src/couchdb/couch_replicate.erl Wed Sep 22 15:15:16 2010
@@ -545,7 +545,10 @@ spawn_missing_revs_finder(StatsProcess, 
 missing_revs_finder_loop(_, _, DocIds, MissingRevsQueue) when is_list(DocIds) ->
     lists:foreach(
         fun(DocId) ->
-            ok = couch_work_queue:queue(MissingRevsQueue, {doc_id, DocId})
+            % Ensure same behaviour as old replicator: accept a list of percent
+            % encoded doc IDs.
+            Id = ?l2b(couch_httpd:unquote(DocId)),
+            ok = couch_work_queue:queue(MissingRevsQueue, {doc_id, Id})
         end, DocIds),
     couch_work_queue:close(MissingRevsQueue);