couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r755575 - in /couchdb/trunk: share/www/script/test/copy_move_doc.js src/couchdb/couch_httpd_db.erl
Date Wed, 18 Mar 2009 12:15:18 GMT
Author: jan
Date: Wed Mar 18 12:15:17 2009
New Revision: 755575

URL: http://svn.apache.org/viewvc?rev=755575&view=rev
Log:
remove MOVE requests as they can't sensibly be supported and COPY & DELETE does the same
thing

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

Modified: couchdb/trunk/share/www/script/test/copy_move_doc.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/copy_move_doc.js?rev=755575&r1=755574&r2=755575&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/copy_move_doc.js (original)
+++ couchdb/trunk/share/www/script/test/copy_move_doc.js Wed Mar 18 12:15:17 2009
@@ -10,7 +10,7 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-couchTests.copy_move_doc = function(debug) {
+couchTests.copy_doc = function(debug) {
   var db = new CouchDB("test_suite_db");
   db.deleteDb();
   db.createDb();
@@ -25,36 +25,19 @@
   T(xhr.status == 201);
   T(db.open("doc_that_was_copied").v == 1);
 
-  // move a doc
-
-  // test error condition
-  var xhr = CouchDB.request("MOVE", "/test_suite_db/doc_to_be_copied", {
-    headers: {"Destination":"doc_that_was_moved"}
-  });
-  T(xhr.status == 400); // bad request, MOVE requires source rev.
-
-  var rev = db.open("doc_to_be_copied")._rev;
-  var xhr = CouchDB.request("MOVE", "/test_suite_db/doc_to_be_copied?rev=" + rev, {
-    headers: {"Destination":"doc_that_was_moved"}
-  });
-
-  T(xhr.status == 201);
-  T(db.open("doc_that_was_moved").v == 1);
-  T(db.open("doc_to_be_copied") == null);
-
   // COPY with existing target
-  T(db.save({_id:"doc_to_be_copied",v:1}).ok);
+  T(db.save({_id:"doc_to_be_copied2",v:1}).ok);
   var doc = db.save({_id:"doc_to_be_overwritten",v:2});
   T(doc.ok);
 
   // error condition
-  var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied", {
+  var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied2", {
       headers: {"Destination":"doc_to_be_overwritten"}
   });
   T(xhr.status == 409); // conflict
 
   var rev = db.open("doc_to_be_overwritten")._rev;
-  var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied", {
+  var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied2", {
     headers: {"Destination":"doc_to_be_overwritten?rev=" + rev}
   });
   T(xhr.status == 201);

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=755575&r1=755574&r2=755575&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Wed Mar 18 12:15:17 2009
@@ -494,33 +494,8 @@
         throw(Error)
     end;
 
-db_doc_req(#httpd{method='MOVE'}=Req, Db, SourceDocId) ->
-    SourceRev = {SourceRevPos, SourceRevId} =
-    case extract_header_rev(Req, couch_httpd:qs_value(Req, "rev")) of
-    missing_rev -> 
-        throw({bad_request, "MOVE requires a specified rev parameter"
-                "for the origin resource."});
-    Rev -> Rev
-    end,
-
-    {TargetDocId, TargetRevs} = parse_copy_destination_header(Req),
-    % open revision Rev or Current
-    Doc = couch_doc_open(Db, SourceDocId, SourceRev, []),
-
-    % save new doc & delete old doc in one operation
-    Docs = [
-        #doc{id=SourceDocId, revs={SourceRevPos, [SourceRevId]}, deleted=true},
-        Doc#doc{id=TargetDocId, revs=TargetRevs}
-        ],
-    {ok, [SourceResult, TargetResult]} = couch_db:update_docs(Db, Docs, []),
-    
-    send_json(Req, 201, {[
-        {SourceDocId, update_result_to_json(SourceResult)},
-        {TargetDocId, update_result_to_json(TargetResult)}
-    ]});
-
 db_doc_req(Req, _Db, _DocId) ->
-    send_method_not_allowed(Req, "DELETE,GET,HEAD,POST,PUT,COPY,MOVE").
+    send_method_not_allowed(Req, "DELETE,GET,HEAD,POST,PUT,COPY").
 
 update_result_to_json({ok, NewRev}) ->
     {[{rev, couch_doc:rev_to_str(NewRev)}]};



Mime
View raw message