couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1171145 - in /couchdb/trunk: Makefile.am src/Makefile.am src/couchdb/couch_ejson_compare.erl src/couchdb/couch_file.erl src/couchdb/couch_httpd.erl src/couchdb/couch_util.erl test/etap/run.tpl test/etap/test_util.erl.in utils/Makefile.am
Date Thu, 15 Sep 2011 15:43:32 GMT
Author: davisp
Date: Thu Sep 15 15:43:32 2011
New Revision: 1171145

URL: http://svn.apache.org/viewvc?rev=1171145&view=rev
Log:
Minor changes for new indexing engine.

This commit makes some minor preparations in various files to prepare
for the new indexer support. This commit holds most of the differences
to existing files.


Modified:
    couchdb/trunk/Makefile.am
    couchdb/trunk/src/Makefile.am
    couchdb/trunk/src/couchdb/couch_ejson_compare.erl
    couchdb/trunk/src/couchdb/couch_file.erl
    couchdb/trunk/src/couchdb/couch_httpd.erl
    couchdb/trunk/src/couchdb/couch_util.erl
    couchdb/trunk/test/etap/run.tpl
    couchdb/trunk/test/etap/test_util.erl.in
    couchdb/trunk/utils/Makefile.am

Modified: couchdb/trunk/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/trunk/Makefile.am?rev=1171145&r1=1171144&r2=1171145&view=diff
==============================================================================
--- couchdb/trunk/Makefile.am (original)
+++ couchdb/trunk/Makefile.am Thu Sep 15 15:43:32 2011
@@ -82,7 +82,7 @@ THANKS.gz: $(top_srcdir)/THANKS
 	-gzip -9 < $< > $@
 
 check: dev
-	$(top_builddir)/test/etap/run
+	$(top_builddir)/test/etap/run test/etap
 
 cover: dev
 	rm -f cover/*.coverdata

Modified: couchdb/trunk/src/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/Makefile.am?rev=1171145&r1=1171144&r2=1171145&view=diff
==============================================================================
--- couchdb/trunk/src/Makefile.am (original)
+++ couchdb/trunk/src/Makefile.am Thu Sep 15 15:43:32 2011
@@ -10,4 +10,11 @@
 ## License for the specific language governing permissions and limitations under
 ## the License.
 
-SUBDIRS = couchdb ejson erlang-oauth etap ibrowse mochiweb snappy
+SUBDIRS = \
+    couchdb \
+    ejson \
+    erlang-oauth \
+    etap \
+    ibrowse \
+    mochiweb \
+    snappy

Modified: couchdb/trunk/src/couchdb/couch_ejson_compare.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_ejson_compare.erl?rev=1171145&r1=1171144&r2=1171145&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_ejson_compare.erl (original)
+++ couchdb/trunk/src/couchdb/couch_ejson_compare.erl Thu Sep 15 15:43:32 2011
@@ -12,7 +12,7 @@
 
 -module(couch_ejson_compare).
 
--export([less/2]).
+-export([less/2, less_json_ids/2, less_json/2]).
 
 -on_load(init/0).
 
@@ -41,6 +41,17 @@ less(A, B) ->
         less_erl(A, B)
     end.
 
+less_json_ids({JsonA, IdA}, {JsonB, IdB}) ->
+    case less(JsonA, JsonB) of
+    0 ->
+        IdA < IdB;
+    Result ->
+        Result < 0
+    end.
+
+less_json(A,B) ->
+    less(A, B) < 0.
+
 
 less_nif(A, B) ->
     less_erl(A, B).

Modified: couchdb/trunk/src/couchdb/couch_file.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_file.erl?rev=1171145&r1=1171144&r2=1171145&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_file.erl (original)
+++ couchdb/trunk/src/couchdb/couch_file.erl Thu Sep 15 15:43:32 2011
@@ -29,7 +29,7 @@
 -export([append_raw_chunk/2, assemble_file_chunk/1, assemble_file_chunk/2]).
 -export([append_term/2, append_term/3, append_term_md5/2, append_term_md5/3]).
 -export([write_header/2, read_header/1]).
--export([delete/2, delete/3, init_delete_dir/1]).
+-export([delete/2, delete/3, nuke_dir/2, init_delete_dir/1]).
 
 % gen_server callbacks
 -export([init/1, terminate/2, code_change/3]).
@@ -214,6 +214,24 @@ delete(RootDir, Filepath, Async) ->
     end.
 
 
+nuke_dir(RootDelDir, Dir) ->
+    FoldFun = fun(File) ->
+        Path = Dir ++ "/" ++ File,
+        case delete(RootDelDir, Path, false) of
+            {error, eperm} -> ok = nuke_dir(RootDelDir, Path);
+            {error, enoent} -> ok;
+            ok -> ok
+        end
+    end,
+    case file:list_dir(Dir) of
+        {ok, Files} ->
+            lists:foreach(FoldFun, Files),
+            ok = file:del_dir(Dir);
+        {error, enoent} ->
+            ok
+    end.
+
+
 init_delete_dir(RootDir) ->
     Dir = filename:join(RootDir,".delete"),
     % note: ensure_dir requires an actual filename companent, which is the

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=1171145&r1=1171144&r2=1171145&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Thu Sep 15 15:43:32 2011
@@ -21,7 +21,8 @@
 -export([verify_is_server_admin/1,unquote/1,quote/1,recv/2,recv_chunked/4,error_info/1]).
 -export([make_fun_spec_strs/1]).
 -export([make_arity_1_fun/1, make_arity_2_fun/1, make_arity_3_fun/1]).
--export([parse_form/1,json_body/1,json_body_obj/1,body/1,doc_etag/1, make_etag/1, etag_respond/3]).
+-export([parse_form/1,json_body/1,json_body_obj/1,body/1]).
+-export([doc_etag/1, make_etag/1, etag_match/2, etag_respond/3, etag_maybe/2]).
 -export([primary_header_value/2,partition/1,serve_file/3,serve_file/4, server_header/0]).
 -export([start_chunked_response/3,send_chunk/2,log_request/2]).
 -export([start_response_length/4, start_response/3, send/2]).
@@ -578,6 +579,14 @@ etag_respond(Req, CurrentEtag, RespFun) 
         RespFun()
     end.
 
+etag_maybe(Req, RespFun) ->
+    try
+        RespFun()
+    catch
+        throw:{etag_match, ETag} ->
+            send_response(Req, 304, [{"ETag", ETag}], <<>>)
+    end.
+
 verify_is_server_admin(#httpd{user_ctx=UserCtx}) ->
     verify_is_server_admin(UserCtx);
 verify_is_server_admin(#user_ctx{roles=Roles}) ->

Modified: couchdb/trunk/src/couchdb/couch_util.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_util.erl?rev=1171145&r1=1171144&r2=1171145&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_util.erl (original)
+++ couchdb/trunk/src/couchdb/couch_util.erl Thu Sep 15 15:43:32 2011
@@ -27,6 +27,8 @@
 -export([reorder_results/2]).
 -export([url_strip_password/1]).
 -export([encode_doc_id/1]).
+-export([with_db/2]).
+-export([doc_member/3]).
 
 -include("couch_db.hrl").
 
@@ -429,3 +431,39 @@ encode_doc_id(<<"_local/", Rest/binary>>
     "_local/" ++ url_encode(Rest);
 encode_doc_id(Id) ->
     url_encode(Id).
+
+
+with_db(Db, Fun) when is_record(Db, db) ->
+    Fun(Db);
+with_db(DbName, Fun) ->
+    case couch_db:open_int(DbName, []) of
+        {ok, Db} ->
+            try
+                Fun(Db)
+            after
+                catch couch_db:close(Db)
+            end;
+        Else ->
+            throw(Else)
+    end.
+
+
+% Rescued from couch_httpd_view.erl, this should really go
+% somewhere else but I can't decide where.
+doc_member(Db, #doc_info{id=Id, revs=[#rev_info{rev=Rev} | _]} = Info, Opts) ->
+    ?LOG_DEBUG("Include Doc: ~p ~p", [Id, Rev]),
+    case couch_db:open_doc(Db, Info, [deleted | Opts]) of
+    {ok, Doc} ->
+        [{doc, couch_doc:to_json_obj(Doc, [])}];
+    _ ->
+        [{doc, null}]
+    end;
+doc_member(Db, {DocId, Rev}, Opts) ->
+    ?LOG_DEBUG("Include Doc: ~p ~p", [DocId, Rev]),
+    case (catch couch_httpd_db:couch_doc_open(Db, DocId, Rev, Opts)) of
+    #doc{} = Doc ->
+        JsonDoc = couch_doc:to_json_obj(Doc, []),
+        [{doc, JsonDoc}];
+    _Else ->
+        [{doc, null}]
+    end.

Modified: couchdb/trunk/test/etap/run.tpl
URL: http://svn.apache.org/viewvc/couchdb/trunk/test/etap/run.tpl?rev=1171145&r1=1171144&r2=1171145&view=diff
==============================================================================
--- couchdb/trunk/test/etap/run.tpl (original)
+++ couchdb/trunk/test/etap/run.tpl Thu Sep 15 15:43:32 2011
@@ -13,15 +13,20 @@
 # the License.
 
 SRCDIR="%abs_top_srcdir%"
-BUILDIR="%abs_top_builddir%"
+BUILDDIR="%abs_top_builddir%"
+export ERL_LIBS="$BUILDDIR/src/:$ERL_LIBS"
+export ERL_FLAGS="$ERL_FLAGS -pa $BUILDDIR/test/etap/"
 
-export ERL_FLAGS="$ERL_FLAGS -pa $BUILDIR/test/etap/"
+if test $# -eq 1; then
+    OPTS=""
+    TGT=$1
+else
+    OPTS=$1
+    TGT=$2
+fi
 
-if test $# -gt 0; then
-    while [ $# -gt 0 ]; do
-        $1
-        shift
-    done
+if test -f $TGT; then
+    prove $OPTS $TGT
 else
-    prove $SRCDIR/test/etap/*.t
+    prove $OPTS $TGT/*.t
 fi

Modified: couchdb/trunk/test/etap/test_util.erl.in
URL: http://svn.apache.org/viewvc/couchdb/trunk/test/etap/test_util.erl.in?rev=1171145&r1=1171144&r2=1171145&view=diff
==============================================================================
--- couchdb/trunk/test/etap/test_util.erl.in (original)
+++ couchdb/trunk/test/etap/test_util.erl.in Thu Sep 15 15:43:32 2011
@@ -14,6 +14,7 @@
 
 -export([init_code_path/0]).
 -export([source_file/1, build_file/1, config_files/0]).
+-export([run/2]).
 
 srcdir() ->
     "@abs_top_srcdir@".
@@ -22,8 +23,15 @@ builddir() ->
     "@abs_top_builddir@".
 
 init_code_path() ->
-    Paths = ["etap", "couchdb", "ejson", "erlang-oauth", "ibrowse", "mochiweb",
-             "snappy"],
+    Paths = [
+        "etap",
+        "couchdb",
+        "ejson",
+        "erlang-oauth",
+        "ibrowse",
+        "mochiweb",
+        "snappy"
+    ],
     lists:foreach(fun(Name) ->
         code:add_patha(filename:join([builddir(), "src", Name]))
     end, Paths).
@@ -40,3 +48,17 @@ config_files() ->
         source_file("test/etap/random_port.ini"),
         build_file("etc/couchdb/local_dev.ini")
     ].
+
+
+run(Plan, Fun) ->
+    test_util:init_code_path(),
+    etap:plan(Plan),
+    case (catch Fun()) of
+        ok ->
+            etap:end_tests();
+        Other ->
+            etap:diag(io_lib:format("Test died abnormally:~n~p", [Other])),
+            timer:sleep(500),
+            etap:bail(Other)
+    end,
+    ok.

Modified: couchdb/trunk/utils/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/trunk/utils/Makefile.am?rev=1171145&r1=1171144&r2=1171145&view=diff
==============================================================================
--- couchdb/trunk/utils/Makefile.am (original)
+++ couchdb/trunk/utils/Makefile.am Thu Sep 15 15:43:32 2011
@@ -23,7 +23,7 @@ run: ../bin/couchdb.tpl
 	    -e "s|%bindir%|$(abs_top_builddir)/bin|g" \
 	    -e "s|%defaultini%|default_dev.ini|g" \
 	    -e "s|%localini%|local_dev.ini|g" \
-	    -e "s|%localerlanglibdir%|foo \
+	    -e "s|%localerlanglibdir%|$(abs_top_builddir)\/src \
 			-pa $(abs_top_builddir)\/src\/couchdb \
 			-pa $(abs_top_builddir)\/src\/ejson \
 			-pa $(abs_top_builddir)\/src\/erlang-oauth \



Mime
View raw message