You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2010/09/30 14:46:57 UTC

svn commit: r1003044 - in /couchdb/trunk: share/www/script/couch.js share/www/script/test/copy_doc.js src/couchdb/couch_httpd_db.erl

Author: rnewson
Date: Thu Sep 30 12:46:57 2010
New Revision: 1003044

URL: http://svn.apache.org/viewvc?rev=1003044&view=rev
Log:
Revert "COUCHDB-903 - add {ok, true} to COPY result."

This reverts commit 5d918e616119e308ca38dc847dd8165e089557dc.

Modified:
    couchdb/trunk/share/www/script/couch.js
    couchdb/trunk/share/www/script/test/copy_doc.js
    couchdb/trunk/src/couchdb/couch_httpd_db.erl

Modified: couchdb/trunk/share/www/script/couch.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch.js?rev=1003044&r1=1003043&r2=1003044&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/couch.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch.js [utf-8] Thu Sep 30 12:46:57 2010
@@ -121,7 +121,7 @@ function CouchDB(name, httpHeaders) {
       CouchDB.maybeThrowError(this.last_req);
       var results = JSON.parse(this.last_req.responseText);
       for (var i = 0; i < docs.length; i++) {
-        if(results[i] && results[i].rev && results[i].ok) {
+        if(results[i] && results[i].rev) {
           docs[i]._rev = results[i].rev;
         }
       }

Modified: couchdb/trunk/share/www/script/test/copy_doc.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/copy_doc.js?rev=1003044&r1=1003043&r2=1003044&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/copy_doc.js (original)
+++ couchdb/trunk/share/www/script/test/copy_doc.js Thu Sep 30 12:46:57 2010
@@ -23,7 +23,6 @@ couchTests.copy_doc = function(debug) {
   });
 
   T(xhr.status == 201);
-  T(JSON.parse(xhr.responseText).ok);
   T(db.open("doc_that_was_copied").v == 1);
 
   // COPY with existing target
@@ -37,10 +36,6 @@ couchTests.copy_doc = function(debug) {
   });
   T(xhr.status == 409); // conflict
 
-  // missing Destination header
-  var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied2");
-  T(xhr.status == 400); // bad request
-
   var rev = db.open("doc_to_be_overwritten")._rev;
   var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied2", {
     headers: {"Destination":"doc_to_be_overwritten?rev=" + rev}

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=1003044&r1=1003043&r2=1003044&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Thu Sep 30 12:46:57 2010
@@ -809,7 +809,7 @@ update_doc_result_to_json({{Id, Rev}, Er
 update_doc_result_to_json(#doc{id=DocId}, Result) ->
     update_doc_result_to_json(DocId, Result);
 update_doc_result_to_json(DocId, {ok, NewRev}) ->
-    {[{ok, true}, {id, DocId}, {rev, couch_doc:rev_to_str(NewRev)}]};
+    {[{id, DocId}, {rev, couch_doc:rev_to_str(NewRev)}]};
 update_doc_result_to_json(DocId, Error) ->
     {_Code, ErrorStr, Reason} = couch_httpd:error_info(Error),
     {[{id, DocId}, {error, ErrorStr}, {reason, Reason}]}.
@@ -1216,19 +1216,15 @@ extract_header_rev(Req, ExplicitRev) ->
 
 
 parse_copy_destination_header(Req) ->
-    case couch_httpd:header_value(Req, "Destination") of
-        undefined ->
-            throw({bad_request, "Destination header is mandatory for COPY"});
-        Destination ->
-            case re:run(Destination, "\\?", [{capture, none}]) of
-                nomatch ->
-                    {list_to_binary(Destination), {0, []}};
-                match ->
-                    [DocId, RevQs] = re:split(Destination, "\\?", [{return, list}]),
-                    [_RevQueryKey, Rev] = re:split(RevQs, "=", [{return, list}]),
-                    {Pos, RevId} = couch_doc:parse_rev(Rev),
-                    {list_to_binary(DocId), {Pos, [RevId]}}
-            end
+    Destination = couch_httpd:header_value(Req, "Destination"),
+    case re:run(Destination, "\\?", [{capture, none}]) of
+    nomatch ->
+        {list_to_binary(Destination), {0, []}};
+    match ->
+        [DocId, RevQs] = re:split(Destination, "\\?", [{return, list}]),
+        [_RevQueryKey, Rev] = re:split(RevQs, "=", [{return, list}]),
+        {Pos, RevId} = couch_doc:parse_rev(Rev),
+        {list_to_binary(DocId), {Pos, [RevId]}}
     end.
 
 validate_attachment_names(Doc) ->