couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nsla...@apache.org
Subject svn commit: r791350 [3/5] - in /couchdb/trunk: etc/couchdb/ share/server/ share/www/ share/www/dialog/ share/www/script/ share/www/script/test/ share/www/style/ src/couchdb/ src/ibrowse/ src/mochiweb/ test/ test/etap/
Date Mon, 06 Jul 2009 00:33:54 GMT
Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Mon Jul  6 00:33:50 2009
@@ -13,7 +13,7 @@
 -module(couch_httpd_db).
 -include("couch_db.hrl").
 
--export([handle_request/1, handle_compact_req/2, handle_design_req/2, 
+-export([handle_request/1, handle_compact_req/2, handle_design_req/2,
     db_req/2, couch_doc_open/4,handle_changes_req/2,
     update_doc_result_to_json/1, update_doc_result_to_json/2,
     handle_design_info_req/2, handle_view_cleanup_req/2]).
@@ -28,7 +28,7 @@
     rev = nil,
     open_revs = []
 }).
-    
+
 % Database request handlers
 handle_request(#httpd{path_parts=[DbName|RestParts],method=Method,
         db_url_handlers=DbUrlHandlers}=Req)->
@@ -86,9 +86,9 @@
             couch_db_update_notifier:stop(Notify),
             get_rest_db_updated() % clean out any remaining update messages
         end;
-        
+
     "false" ->
-        {ok, {LastSeq, _Prepend}} = 
+        {ok, {LastSeq, _Prepend}} =
                 send_changes(Req, Resp, Db, StartSeq, <<"">>),
         send_chunk(Resp, io_lib:format("\n],\n\"last_seq\":~w}\n", [LastSeq])),
         send_chunk(Resp, "")
@@ -106,7 +106,7 @@
         stop -> stop
         end
     end.
-    
+
 get_rest_db_updated() ->
     receive db_updated -> get_rest_db_updated()
     after 0 -> updated
@@ -127,7 +127,7 @@
 send_changes(Req, Resp, Db, StartSeq, Prepend0) ->
     Style = list_to_existing_atom(
             couch_httpd:qs_value(Req, "style", "main_only")),
-    couch_db:changes_since(Db, Style, StartSeq, 
+    couch_db:changes_since(Db, Style, StartSeq,
         fun([#doc_info{id=Id, high_seq=Seq}|_]=DocInfos, {_, Prepend}) ->
             FilterFun =
             fun(#doc_info{revs=[#rev_info{rev=Rev}|_]}) ->
@@ -139,7 +139,7 @@
             [] ->
                 {ok, {Seq, Prepend}};
             _ ->
-                send_chunk(Resp, 
+                send_chunk(Resp,
                     [Prepend, ?JSON_ENCODE({[{seq,Seq}, {id, Id},
                                               {changes,Results}]})]),
                 {ok, {Seq, <<",\n">>}}
@@ -172,7 +172,7 @@
     }=Req, Db) ->
     Handler = couch_util:dict_find(Action, DesignUrlHandlers, fun db_req/2),
     Handler(Req, Db);
-    
+
 handle_design_req(Req, Db) ->
     db_req(Req, Db).
 
@@ -188,7 +188,7 @@
         {name, DesignName},
         {view_index, {GroupInfoList}}
     ]});
-    
+
 handle_design_info_req(Req, _Db) ->
     send_method_not_allowed(Req, "GET").
 
@@ -244,7 +244,7 @@
     _Normal ->
         % normal
         {ok, NewRev} = couch_db:update_doc(Db, Doc#doc{id=DocId}, []),
-        DocUrl = absolute_uri(Req, 
+        DocUrl = absolute_uri(Req,
             binary_to_list(<<"/",DbName/binary,"/",DocId/binary>>)),
         send_json(Req, 201, [{"Location", DocUrl}], {[
             {ok, true},
@@ -265,7 +265,7 @@
             {ok, true},
             {instance_start_time, DbStartTime}
         ]});
-    
+
 db_req(#httpd{path_parts=[_,<<"_ensure_full_commit">>]}=Req, _Db) ->
     send_method_not_allowed(Req, "POST");
 
@@ -311,14 +311,14 @@
                 Docs, Results),
             send_json(Req, 201, DocResults);
         {aborted, Errors} ->
-            ErrorsJson = 
+            ErrorsJson =
                 lists:map(fun update_doc_result_to_json/1, Errors),
             send_json(Req, 417, ErrorsJson)
         end;
     false ->
         Docs = [couch_doc:from_json_obj(JsonObj) || JsonObj <- DocsArray],
         {ok, Errors} = couch_db:update_docs(Db, Docs, Options, replicated_changes),
-        ErrorsJson = 
+        ErrorsJson =
             lists:map(fun update_doc_result_to_json/1, Errors),
         send_json(Req, 201, ErrorsJson)
     end;
@@ -328,7 +328,7 @@
 db_req(#httpd{method='POST',path_parts=[_,<<"_purge">>]}=Req, Db) ->
     {IdsRevs} = couch_httpd:json_body_obj(Req),
     IdsRevs2 = [{Id, couch_doc:parse_revs(Revs)} || {Id, Revs} <- IdsRevs],
-    
+
     case couch_db:purge_docs(Db, IdsRevs2) of
     {ok, PurgeSeq, PurgedIdsRevs} ->
         PurgedIdsRevs2 = [{Id, couch_doc:rev_to_strs(Revs)} || {Id, Revs} <- PurgedIdsRevs],
@@ -339,7 +339,7 @@
 
 db_req(#httpd{path_parts=[_,<<"_purge">>]}=Req, _Db) ->
     send_method_not_allowed(Req, "POST");
-   
+
 db_req(#httpd{method='GET',path_parts=[_,<<"_all_docs">>]}=Req, Db) ->
     all_docs_view(Req, Db, nil);
 
@@ -357,7 +357,7 @@
 
 db_req(#httpd{path_parts=[_,<<"_all_docs">>]}=Req, _Db) ->
     send_method_not_allowed(Req, "GET,HEAD,POST");
-    
+
 db_req(#httpd{method='GET',path_parts=[_,<<"_all_docs_by_seq">>]}=Req, Db) ->
     #view_query_args{
         start_key = StartKey,
@@ -450,18 +450,18 @@
 db_req(#httpd{path_parts=[_,<<"_revs_limit">>]}=Req, _Db) ->
     send_method_not_allowed(Req, "PUT,GET");
 
-% Special case to enable using an unencoded slash in the URL of design docs, 
+% Special case to enable using an unencoded slash in the URL of design docs,
 % as slashes in document IDs must otherwise be URL encoded.
 db_req(#httpd{method='GET',mochi_req=MochiReq, path_parts=[DbName,<<"_design/",_/binary>>|_]}=Req, _Db) ->
     PathFront = "/" ++ couch_httpd:quote(binary_to_list(DbName)) ++ "/",
     RawSplit = regexp:split(MochiReq:get(raw_path),"_design%2F"),
     {ok, [PathFront|PathTail]} = RawSplit,
-    couch_httpd:send_redirect(Req, PathFront ++ "_design/" ++ 
+    couch_httpd:send_redirect(Req, PathFront ++ "_design/" ++
         mochiweb_util:join(PathTail, "_design%2F"));
 
 db_req(#httpd{path_parts=[_DbName,<<"_design">>,Name]}=Req, Db) ->
     db_doc_req(Req, Db, <<"_design/",Name/binary>>);
-    
+
 db_req(#httpd{path_parts=[_DbName,<<"_design">>,Name|FileNameParts]}=Req, Db) ->
     db_attachment_req(Req, Db, <<"_design/",Name/binary>>, FileNameParts);
 
@@ -472,7 +472,7 @@
 db_req(#httpd{path_parts=[_, DocId | FileNameParts]}=Req, Db) ->
     db_attachment_req(Req, Db, DocId, FileNameParts).
 
-all_docs_view(Req, Db, Keys) -> 
+all_docs_view(Req, Db, Keys) ->
     #view_query_args{
         start_key = StartKey,
         start_docid = StartDocId,
@@ -483,17 +483,17 @@
     } = QueryArgs = couch_httpd_view:parse_view_params(Req, Keys, map),
     {ok, Info} = couch_db:get_db_info(Db),
     CurrentEtag = couch_httpd:make_etag(proplists:get_value(update_seq, Info)),
-    couch_httpd:etag_respond(Req, CurrentEtag, fun() -> 
-    
+    couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
+
         TotalRowCount = proplists:get_value(doc_count, Info),
         StartId = if is_binary(StartKey) -> StartKey;
         true -> StartDocId
         end,
         FoldAccInit = {Limit, SkipCount, undefined, []},
-        
+
         case Keys of
         nil ->
-            PassedEndFun = 
+            PassedEndFun =
             case Dir of
             fwd ->
                 fun(ViewKey, _ViewId) ->
@@ -504,7 +504,7 @@
                     couch_db_updater:less_docid(ViewKey, EndKey)
                 end
             end,
-            
+
             FoldlFun = couch_httpd_view:make_view_fold_fun(Req, QueryArgs, CurrentEtag, Db,
                 TotalRowCount, #view_fold_helper_funs{
                     reduce_count = fun couch_db:enum_docs_reduce_to_count/1,
@@ -518,7 +518,7 @@
                     {ok, Acc}
                 end
             end,
-            {ok, FoldResult} = couch_db:enum_docs(Db, StartId, Dir, 
+            {ok, FoldResult} = couch_db:enum_docs(Db, StartId, Dir,
                 AdapterFun, FoldAccInit),
             couch_httpd_view:finish_view_fold(Req, TotalRowCount, {ok, FoldResult});
         _ ->
@@ -554,7 +554,7 @@
                         Acc
                     end
                 end, {ok, FoldAccInit}, Keys),
-            couch_httpd_view:finish_view_fold(Req, TotalRowCount, {ok, FoldResult})        
+            couch_httpd_view:finish_view_fold(Req, TotalRowCount, {ok, FoldResult})
         end
     end).
 
@@ -580,7 +580,7 @@
     [] ->
         Doc = couch_doc_open(Db, DocId, Rev, Options),
         DiskEtag = couch_httpd:doc_etag(Doc),
-        couch_httpd:etag_respond(Req, DiskEtag, fun() -> 
+        couch_httpd:etag_respond(Req, DiskEtag, fun() ->
             Headers = case Doc#doc.meta of
             [] -> [{"Etag", DiskEtag}]; % output etag only when we have no meta
             _ -> []
@@ -668,10 +668,10 @@
     % open old doc
     Doc = couch_doc_open(Db, SourceDocId, SourceRev, []),
     % save new doc
-    {ok, NewTargetRev} = couch_db:update_doc(Db, 
-        Doc#doc{id=TargetDocId, revs=TargetRevs}, []), 
+    {ok, NewTargetRev} = couch_db:update_doc(Db,
+        Doc#doc{id=TargetDocId, revs=TargetRevs}, []),
     % respond
-    send_json(Req, 201, 
+    send_json(Req, 201,
         [{"Etag", "\"" ++ ?b2l(couch_doc:rev_to_str(NewTargetRev)) ++ "\""}],
         update_doc_result_to_json(TargetDocId, {ok, NewTargetRev}));
 
@@ -698,7 +698,7 @@
 
 update_doc(Req, Db, DocId, Json, Headers) ->
     #doc{deleted=Deleted} = Doc = couch_doc_from_req(Req, DocId, Json),
-    
+
     case couch_httpd:header_value(Req, "X-Couch-Full-Commit", "false") of
     "true" ->
         Options = [full_commit];
@@ -729,7 +729,7 @@
         Revs = {Pos, [Rev]}
     end,
     Doc#doc{id=DocId, revs=Revs}.
-    
+
 
 % Useful for debugging
 % couch_doc_open(Db, DocId) ->
@@ -758,13 +758,13 @@
 db_attachment_req(#httpd{method='GET'}=Req, Db, DocId, FileNameParts) ->
     FileName = list_to_binary(mochiweb_util:join(lists:map(fun binary_to_list/1, FileNameParts),"/")),
     #doc_query_args{
-        rev=Rev, 
+        rev=Rev,
         options=Options
     } = parse_doc_query(Req),
     #doc{
         attachments=Attachments
     } = Doc = couch_doc_open(Db, DocId, Rev, Options),
-    
+
     case proplists:get_value(FileName, Attachments) of
     undefined ->
         throw({not_found, "Document is missing attachment"});
@@ -789,9 +789,9 @@
         when (Method == 'PUT') or (Method == 'DELETE') ->
     FileName = validate_attachment_name(
                     mochiweb_util:join(
-                        lists:map(fun binary_to_list/1, 
+                        lists:map(fun binary_to_list/1,
                             FileNameParts),"/")),
-    
+
     NewAttachment = case Method of
         'DELETE' ->
             [];
@@ -807,12 +807,12 @@
                     list_to_binary(CType)
                 end,
                 case couch_httpd:header_value(Req,"Content-Length") of
-                undefined -> 
-                    {fun(MaxChunkSize, ChunkFun, InitState) -> 
-                        couch_httpd:recv_chunked(Req, MaxChunkSize, 
-                            ChunkFun, InitState) 
+                undefined ->
+                    {fun(MaxChunkSize, ChunkFun, InitState) ->
+                        couch_httpd:recv_chunked(Req, MaxChunkSize,
+                            ChunkFun, InitState)
                     end, undefined};
-                Length -> 
+                Length ->
                     {fun() -> couch_httpd:recv(Req, 0) end,
                         list_to_integer(Length)}
                 end
@@ -901,7 +901,7 @@
 parse_copy_destination_header(Req) ->
     Destination = couch_httpd:header_value(Req, "Destination"),
     case regexp:match(Destination, "\\?") of
-    nomatch -> 
+    nomatch ->
         {list_to_binary(Destination), {0, []}};
     {match, _, _} ->
         {ok, [DocId, RevQueryOptions]} = regexp:split(Destination, "\\?"),
@@ -911,7 +911,7 @@
     end.
 
 validate_attachment_names(Doc) ->
-    lists:foreach(fun({Name, _}) -> 
+    lists:foreach(fun({Name, _}) ->
         validate_attachment_name(Name)
     end, Doc#doc.attachments).
 

Modified: couchdb/trunk/src/couchdb/couch_httpd_external.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_external.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_external.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_external.erl Mon Jul  6 00:33:50 2009
@@ -34,7 +34,7 @@
 handle_external_req(Req, _) ->
     send_error(Req, 404, <<"external_server_error">>, <<"Broken assumption">>).
 
-% handle_external_req/3 
+% handle_external_req/3
 % for this type of config usage:
 % _action = {couch_httpd_external, handle_external_req, <<"action">>}
 % with urls like
@@ -44,7 +44,7 @@
 
 process_external_req(HttpReq, Db, Name) ->
 
-    Response = couch_external_manager:execute(binary_to_list(Name), 
+    Response = couch_external_manager:execute(binary_to_list(Name),
         json_req_obj(HttpReq, Db)),
 
     case Response of
@@ -54,7 +54,7 @@
         send_external_response(HttpReq, Response)
     end.
 
-json_req_obj(#httpd{mochi_req=Req, 
+json_req_obj(#httpd{mochi_req=Req,
                method=Verb,
                path_parts=Path,
                req_body=ReqBody
@@ -99,7 +99,7 @@
         ctype = CType,
         headers = Headers
     } = parse_external_response(Response),
-    Resp = MochiReq:respond({Code, 
+    Resp = MochiReq:respond({Code,
         default_or_content_type(CType, Headers ++ couch_httpd:server_header()), Data}),
     {ok, Resp}.
 
@@ -120,7 +120,7 @@
                 Args#extern_resp_args{data=Value, ctype="text/html; charset=utf-8"};
             {<<"base64">>, Value} ->
                 Args#extern_resp_args{
-                    data=couch_util:decodeBase64(Value),        
+                    data=couch_util:decodeBase64(Value),
                     ctype="application/binary"
                 };
             {<<"headers">>, {Headers}} ->

Modified: couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl Mon Jul  6 00:33:50 2009
@@ -16,7 +16,7 @@
     handle_all_dbs_req/1,handle_replicate_req/1,handle_restart_req/1,
     handle_uuids_req/1,handle_config_req/1,handle_log_req/1,
     handle_task_status_req/1,handle_sleep_req/1,handle_whoami_req/1]).
-    
+
 -export([increment_update_seq_req/2]).
 
 
@@ -41,7 +41,7 @@
     couch_httpd:serve_file(Req, "favicon.ico", DocumentRoot);
 handle_favicon_req(Req, _) ->
     send_method_not_allowed(Req, "GET,HEAD").
-    
+
 handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
     "/" ++ UrlPath = couch_httpd:path(Req),
     case couch_httpd:partition(UrlPath) of
@@ -83,7 +83,7 @@
     $/ -> Url;
     _  -> Url ++ "/"
     end).
-    
+
 
 get_rep_endpoint(_Req, {Props}) ->
     Url = proplists:get_value(<<"url">>, Props),
@@ -136,7 +136,7 @@
 
 % Config request handler
 
-    
+
 % GET /_config/
 % GET /_config
 handle_config_req(#httpd{method='GET', path_parts=[_]}=Req) ->

Modified: couchdb/trunk/src/couchdb/couch_httpd_show.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_show.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_show.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_show.erl Mon Jul  6 00:33:50 2009
@@ -11,7 +11,7 @@
 % the License.
 
 -module(couch_httpd_show).
-    
+
 -export([handle_doc_show_req/2, handle_view_list_req/2]).
 
 
@@ -21,7 +21,7 @@
     [send_json/2,send_json/3,send_json/4,send_method_not_allowed/2,
     start_json_response/2,send_chunk/2,send_chunked_error/2,
     start_chunked_response/3, send_error/4]).
-    
+
 handle_doc_show_req(#httpd{
         method='GET',
         path_parts=[_DbName, _Design, DesignName, _Show, ShowName, DocId]
@@ -93,7 +93,7 @@
     Stale = couch_httpd_view:get_stale_type(Req),
     Reduce = couch_httpd_view:get_reduce_type(Req),
     case couch_view:get_map_view(Db, DesignId, ViewName, Stale) of
-    {ok, View, Group} ->    
+    {ok, View, Group} ->
         QueryArgs = couch_httpd_view:parse_view_params(Req, Keys, map),
         output_map_list(Req, Lang, ListSrc, View, Group, Db, QueryArgs, Keys);
     {not_found, _Reason} ->
@@ -139,7 +139,7 @@
 
         StartListRespFun = make_map_start_resp_fun(QueryServer, Db),
         SendListRowFun = make_map_send_row_fun(QueryServer),
-    
+
         FoldlFun = couch_httpd_view:make_view_fold_fun(Req, QueryArgs, CurrentEtag, Db, RowCount,
             #view_fold_helper_funs{
                 reduce_count = fun couch_view:reduce_to_count/1,
@@ -200,7 +200,7 @@
     end.
 
 start_list_resp(QueryServer, Req, Db, Head, Etag) ->
-    [<<"start">>,Chunks,JsonResp] = couch_query_servers:render_list_head(QueryServer, 
+    [<<"start">>,Chunks,JsonResp] = couch_query_servers:render_list_head(QueryServer,
         Req, Db, Head),
     JsonResp2 = apply_etag(JsonResp, Etag),
     #extern_resp_args{
@@ -266,9 +266,9 @@
     couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
         StartListRespFun = make_reduce_start_resp_fun(QueryServer, Req, Db, CurrentEtag),
         SendListRowFun = make_reduce_send_row_fun(QueryServer, Db),
-    
-        {ok, GroupRowsFun, RespFun} = couch_httpd_view:make_reduce_fold_funs(Req, 
-            GroupLevel, QueryArgs, CurrentEtag, 
+
+        {ok, GroupRowsFun, RespFun} = couch_httpd_view:make_reduce_fold_funs(Req,
+            GroupLevel, QueryArgs, CurrentEtag,
             #reduce_fold_helper_funs{
                 start_response = StartListRespFun,
                 send_row = SendListRowFun
@@ -300,9 +300,9 @@
     couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
         StartListRespFun = make_reduce_start_resp_fun(QueryServer, Req, Db, CurrentEtag),
         SendListRowFun = make_reduce_send_row_fun(QueryServer, Db),
-    
+
         {ok, GroupRowsFun, RespFun} = couch_httpd_view:make_reduce_fold_funs(Req,
-            GroupLevel, QueryArgs, CurrentEtag, 
+            GroupLevel, QueryArgs, CurrentEtag,
             #reduce_fold_helper_funs{
                 start_response = StartListRespFun,
                 send_row = SendListRowFun
@@ -319,7 +319,7 @@
 finish_list(Req, QueryServer, Etag, FoldResult, StartFun, TotalRows) ->
     case FoldResult of
         {_, _, undefined, _} ->
-            {ok, Resp, BeginBody} = 
+            {ok, Resp, BeginBody} =
                 render_head_for_empty_list(StartFun, Req, Etag, TotalRows),
             [<<"end">>, Chunks] = couch_query_servers:render_list_tail(QueryServer),
             Chunk = BeginBody ++ ?b2l(?l2b(Chunks)),
@@ -343,8 +343,8 @@
     Hlist = mochiweb_headers:to_list(Headers),
     Accept = proplists:get_value('Accept', Hlist),
     CurrentEtag = couch_httpd:make_etag({Lang, ShowSrc, nil, Accept}),
-    couch_httpd:etag_respond(Req, CurrentEtag, fun() -> 
-        [<<"resp">>, ExternalResp] = couch_query_servers:render_doc_show(Lang, ShowSrc, 
+    couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
+        [<<"resp">>, ExternalResp] = couch_query_servers:render_doc_show(Lang, ShowSrc,
             DocId, nil, Req, Db),
         JsonResp = apply_etag(ExternalResp, CurrentEtag),
         couch_httpd_external:send_external_response(Req, JsonResp)
@@ -356,9 +356,9 @@
     Hlist = mochiweb_headers:to_list(Headers),
     Accept = proplists:get_value('Accept', Hlist),
     CurrentEtag = couch_httpd:make_etag({Lang, ShowSrc, Revs, Accept}),
-    % We know our etag now    
-    couch_httpd:etag_respond(Req, CurrentEtag, fun() -> 
-        [<<"resp">>, ExternalResp] = couch_query_servers:render_doc_show(Lang, ShowSrc, 
+    % We know our etag now
+    couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
+        [<<"resp">>, ExternalResp] = couch_query_servers:render_doc_show(Lang, ShowSrc,
             DocId, Doc, Req, Db),
         JsonResp = apply_etag(ExternalResp, CurrentEtag),
         couch_httpd_external:send_external_response(Req, JsonResp)
@@ -378,9 +378,9 @@
     [{Key, NewValue}|Acc].
 
 apply_etag({ExternalResponse}, CurrentEtag) ->
-    % Here we embark on the delicate task of replacing or creating the  
-    % headers on the JsonResponse object. We need to control the Etag and 
-    % Vary headers. If the external function controls the Etag, we'd have to 
+    % Here we embark on the delicate task of replacing or creating the
+    % headers on the JsonResponse object. We need to control the Etag and
+    % Vary headers. If the external function controls the Etag, we'd have to
     % run it to check for a match, which sort of defeats the purpose.
     case proplists:get_value(<<"headers">>, ExternalResponse, nil) of
     nil ->
@@ -397,4 +397,4 @@
             Field
         end || Field <- ExternalResponse]}
     end.
-    
+

Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Mon Jul  6 00:33:50 2009
@@ -83,12 +83,12 @@
     case proplists:get_value(<<"reduce">>, Props, null) of
     null ->
         QueryArgs = parse_view_params(Req, Keys, map),
-        {ok, View, Group} = couch_view:get_temp_map_view(Db, Language, 
+        {ok, View, Group} = couch_view:get_temp_map_view(Db, Language,
             DesignOptions, MapSrc),
         output_map_view(Req, View, Group, Db, QueryArgs, Keys);
     RedSrc ->
         QueryArgs = parse_view_params(Req, Keys, reduce),
-        {ok, View, Group} = couch_view:get_temp_reduce_view(Db, Language, 
+        {ok, View, Group} = couch_view:get_temp_reduce_view(Db, Language,
             DesignOptions, MapSrc, RedSrc),
         output_reduce_view(Req, View, Group, QueryArgs, Keys)
     end;
@@ -105,7 +105,7 @@
         start_docid = StartDocId
     } = QueryArgs,
     CurrentEtag = view_group_etag(Group),
-    couch_httpd:etag_respond(Req, CurrentEtag, fun() -> 
+    couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
         {ok, RowCount} = couch_view:get_row_count(View),
         Start = {StartKey, StartDocId},
         FoldlFun = make_view_fold_fun(Req, QueryArgs, CurrentEtag, Db, RowCount, #view_fold_helper_funs{reduce_count=fun couch_view:reduce_to_count/1}),
@@ -113,7 +113,7 @@
         FoldResult = couch_view:fold(View, Start, Dir, FoldlFun, FoldAccInit),
         finish_view_fold(Req, RowCount, FoldResult)
     end);
-    
+
 output_map_view(Req, View, Group, Db, QueryArgs, Keys) ->
     #view_query_args{
         limit = Limit,
@@ -122,7 +122,7 @@
         start_docid = StartDocId
     } = QueryArgs,
     CurrentEtag = view_group_etag(Group, Keys),
-    couch_httpd:etag_respond(Req, CurrentEtag, fun() ->     
+    couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
         {ok, RowCount} = couch_view:get_row_count(View),
         FoldAccInit = {Limit, SkipCount, undefined, []},
         FoldResult = lists:foldl(
@@ -132,7 +132,7 @@
                     QueryArgs#view_query_args{
                         start_key = Key,
                         end_key = Key
-                    }, CurrentEtag, Db, RowCount, 
+                    }, CurrentEtag, Db, RowCount,
                     #view_fold_helper_funs{
                         reduce_count = fun couch_view:reduce_to_count/1
                     }),
@@ -156,11 +156,11 @@
     couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
         {ok, GroupRowsFun, RespFun} = make_reduce_fold_funs(Req, GroupLevel, QueryArgs, CurrentEtag, #reduce_fold_helper_funs{}),
         FoldAccInit = {Limit, Skip, undefined, []},
-        {ok, {_, _, Resp, _}} = couch_view:fold_reduce(View, Dir, {StartKey, StartDocId}, 
+        {ok, {_, _, Resp, _}} = couch_view:fold_reduce(View, Dir, {StartKey, StartDocId},
             {EndKey, EndDocId}, GroupRowsFun, RespFun, FoldAccInit),
         finish_reduce_fold(Req, Resp)
     end);
-    
+
 output_reduce_view(Req, View, Group, QueryArgs, Keys) ->
     #view_query_args{
         limit = Limit,
@@ -177,7 +177,7 @@
             fun(Key, {Resp, RedAcc}) ->
                 % run the reduce once for each key in keys, with limit etc reapplied for each key
                 FoldAccInit = {Limit, Skip, Resp, RedAcc},
-                {_, {_, _, Resp2, RedAcc2}} = couch_view:fold_reduce(View, Dir, {Key, StartDocId}, 
+                {_, {_, _, Resp2, RedAcc2}} = couch_view:fold_reduce(View, Dir, {Key, StartDocId},
                     {Key, EndDocId}, GroupRowsFun, RespFun, FoldAccInit),
                 % Switch to comma
                 {Resp2, RedAcc2}
@@ -198,7 +198,7 @@
 
 parse_view_params(Req, Keys, ViewType) ->
     QueryList = couch_httpd:qs(Req),
-    QueryParams = 
+    QueryParams =
     lists:foldl(fun({K, V}, Acc) ->
             parse_view_param(K, V) ++ Acc
         end, [], QueryList),
@@ -360,13 +360,13 @@
         inclusive_end = InclusiveEnd,
         direction = Dir
     } = QueryArgs,
-    
+
     #view_fold_helper_funs{
         passed_end = PassedEndFun,
         start_response = StartRespFun,
         send_row = SendRowFun,
         reduce_count = ReduceCountFun
-    } = apply_default_helper_funs(HelperFuns, 
+    } = apply_default_helper_funs(HelperFuns,
         {Dir, EndKey, EndDocId, InclusiveEnd}),
 
     #view_query_args{
@@ -390,12 +390,12 @@
             Offset = ReduceCountFun(OffsetReds),
             {ok, Resp2, RowFunAcc0} = StartRespFun(Req, Etag,
                 TotalViewCount, Offset, RowFunAcc),
-            {Go, RowFunAcc2} = SendRowFun(Resp2, Db, {{Key, DocId}, Value}, 
+            {Go, RowFunAcc2} = SendRowFun(Resp2, Db, {{Key, DocId}, Value},
                 IncludeDocs, RowFunAcc0),
             {Go, {AccLimit - 1, 0, Resp2, RowFunAcc2}};
         {_, AccLimit, _, Resp} when (AccLimit > 0) ->
             % rendering all other rows
-            {Go, RowFunAcc2} = SendRowFun(Resp, Db, {{Key, DocId}, Value}, 
+            {Go, RowFunAcc2} = SendRowFun(Resp, Db, {{Key, DocId}, Value},
                 IncludeDocs, RowFunAcc),
             {Go, {AccLimit - 1, 0, Resp, RowFunAcc2}}
         end
@@ -439,7 +439,7 @@
             when is_integer(GroupLevel), is_list(Key) ->
         % group_level and we haven't responded yet
         {ok, Resp2, RowAcc} = StartRespFun(Req, Etag, RowAcc0),
-        {Go, RowAcc2} = SendRowFun(Resp2, {lists:sublist(Key, GroupLevel), Red}, RowAcc),    
+        {Go, RowAcc2} = SendRowFun(Resp2, {lists:sublist(Key, GroupLevel), Red}, RowAcc),
         {Go, {AccLimit - 1, 0, Resp2, RowAcc2}};
     (Key, Red, {AccLimit, 0, Resp, RowAcc})
             when is_integer(GroupLevel), is_list(Key) ->
@@ -551,15 +551,15 @@
 
 send_json_reduce_row(Resp, {Key, Value}, RowFront) ->
     send_chunk(Resp, RowFront ++ ?JSON_ENCODE({[{key, Key}, {value, Value}]})),
-    {ok, ",\r\n"}.    
+    {ok, ",\r\n"}.
 
 view_group_etag(Group) ->
     view_group_etag(Group, nil).
-    
+
 view_group_etag(#group{sig=Sig,current_seq=CurrentSeq}, Extra) ->
     % This is not as granular as it could be.
     % If there are updates to the db that do not effect the view index,
-    % they will change the Etag. For more granular Etags we'd need to keep 
+    % they will change the Etag. For more granular Etags we'd need to keep
     % track of the last Db seq that caused an index change.
     couch_httpd:make_etag({Sig, CurrentSeq, Extra}).
 
@@ -591,10 +591,10 @@
       {not_found, deleted} ->
           {[{id, DocId}, {key, Key}, {value, Value}]};
       Doc ->
-        JsonDoc = couch_doc:to_json_obj(Doc, []), 
+        JsonDoc = couch_doc:to_json_obj(Doc, []),
         {[{id, DocId}, {key, Key}, {value, Value}, {doc, JsonDoc}]}
     end.
-    
+
 finish_view_fold(Req, TotalRows, FoldResult) ->
     case FoldResult of
     {ok, {_, _, undefined, _}} ->

Modified: couchdb/trunk/src/couchdb/couch_js.c
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_js.c?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_js.c (original)
+++ couchdb/trunk/src/couchdb/couch_js.c Mon Jul  6 00:33:50 2009
@@ -489,12 +489,12 @@
   jsmsg = JS_ValueToString(context,*arg);
   len = JS_GetStringLength(jsmsg);
   tmp = JS_GetStringBytes(jsmsg);
-      
+
   c = (char*)malloc(len+1);
   c[len] = '\0';
 
   int i;
- 
+
   for(i = 0;i < len;i++) {
     c[i] = tmp[i];
   }
@@ -541,11 +541,11 @@
     }
 
     JSObject* iterator = JS_NewPropertyIterator(context,header_obj);
-    
+
     jsval *jsProperty = JS_malloc(context,sizeof(jsval));
     jsval *jsValue = JS_malloc(context,sizeof(jsval));
     jsid *jsId = JS_malloc(context,sizeof(jsid));
-    
+
     while(JS_NextProperty(context,iterator,jsId) == JS_TRUE) {
 
       if(*jsId == JSVAL_VOID) {
@@ -569,7 +569,7 @@
       append_Buffer(bTmp,"",1);
 
       slist = curl_slist_append(slist,bTmp->data);
-      
+
       free_Buffer(bTmp);
       free(jsPropertyValue);
       free(jsPropertyName);
@@ -595,7 +595,7 @@
 
   // Run GC
   JS_MaybeGC(context);
-  
+
   // Init Curl
   if((handle = curl_easy_init()) == NULL) {
     return JS_FALSE;
@@ -616,7 +616,7 @@
   curl_easy_setopt(handle,CURLOPT_WRITEHEADER,b);
   curl_easy_setopt(handle,CURLOPT_URL,url);
   curl_easy_setopt(handle,CURLOPT_HTTPGET,1);
-  curl_easy_setopt(handle,CURLOPT_FOLLOWLOCATION,1);  
+  curl_easy_setopt(handle,CURLOPT_FOLLOWLOCATION,1);
   curl_easy_setopt(handle,CURLOPT_NOPROGRESS,1);
   curl_easy_setopt(handle,CURLOPT_IPRESOLVE,CURL_IPRESOLVE_V4);
 
@@ -654,7 +654,7 @@
   /* Shrink the buffer to the real size  and store its value in rval */
   shrink_Buffer(b);
   BufferToJSVal(context,b,rval);
-  
+
   // Free Buffer
   free_Buffer(b);
 
@@ -679,7 +679,7 @@
 
   // Run GC
   JS_MaybeGC(context);
-  
+
   // Init Curl
   if((handle = curl_easy_init()) == NULL) {
     return JS_FALSE;
@@ -741,7 +741,7 @@
   /* Shrink the buffer to the real size  and store its value in rval */
   shrink_Buffer(b);
   BufferToJSVal(context,b,rval);
-  
+
   // Free Buffer
   free_Buffer(b);
 
@@ -803,7 +803,7 @@
 
   struct curl_slist *slist = generateCurlHeaders(context,argv+2); // Initialize Headers
   if(slist != NULL) {
-    curl_easy_setopt(handle,CURLOPT_HTTPHEADER,slist);            
+    curl_easy_setopt(handle,CURLOPT_HTTPHEADER,slist);
   }
 
   int exitcode;
@@ -858,17 +858,17 @@
 
   // Allocate buffer that will store the get resultant
   b = init_Buffer();
-  
+
   // Allocate data buffer and move data into them
   b_data = (BufferCount)malloc(sizeof(Buffer) + sizeof(int));
   b_data->buffer = init_Buffer();
   b_data->pos = 0;
-  
+
   data = JSValToChar(context,(argv+1));
   readlen = strlen(data);
-  
 
-  
+
+
   // TODO: remove strlen
   append_Buffer(b_data->buffer,data,readlen);
 
@@ -893,7 +893,7 @@
   curl_easy_setopt(handle,CURLOPT_URL,url);
   curl_easy_setopt(handle,CURLOPT_UPLOAD,1);
   curl_easy_setopt(handle,CURLOPT_INFILESIZE,readlen);
-  
+
 
 
   // Curl structure
@@ -908,11 +908,11 @@
   // Use only ipv4
   curl_easy_setopt(handle,CURLOPT_IPRESOLVE,CURL_IPRESOLVE_V4);
 
-  
+
 
   // Perform
   int exitcode;
-  
+
   if((exitcode = curl_easy_perform(handle)) != 0) {
     if(slist != NULL)
       curl_slist_free_all(slist);
@@ -939,7 +939,7 @@
   shrink_Buffer(b);
 
   BufferToJSVal(context,b,rval);
-  
+
   free_Buffer(b);
 
   if(rval == NULL) {
@@ -1023,7 +1023,7 @@
   shrink_Buffer(b);
 
   BufferToJSVal(context,b,rval);
-  
+
   if(rval == NULL) {
     curl_easy_cleanup(handle);
     return JS_FALSE;
@@ -1105,7 +1105,7 @@
   shrink_Buffer(b);
 
   BufferToJSVal(context,b,rval);
-  
+
   if(rval == NULL) {
     curl_easy_cleanup(handle);
     return JS_FALSE;
@@ -1187,7 +1187,7 @@
   shrink_Buffer(b);
 
   BufferToJSVal(context,b,rval);
-  
+
   if(rval == NULL) {
     curl_easy_cleanup(handle);
     return JS_FALSE;

Modified: couchdb/trunk/src/couchdb/couch_key_tree.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_key_tree.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_key_tree.erl (original)
+++ couchdb/trunk/src/couchdb/couch_key_tree.erl Mon Jul  6 00:33:50 2009
@@ -26,14 +26,14 @@
 % partial trees arranged by how much they are cut off.
 
 merge(A, B) ->
-    {Merged, HasConflicts} = 
+    {Merged, HasConflicts} =
     lists:foldl(
         fun(InsertTree, {AccTrees, AccConflicts}) ->
             {ok, Merged, Conflicts} = merge_one(AccTrees, InsertTree, [], false),
             {Merged, Conflicts or AccConflicts}
         end,
         {A, false}, B),
-    if HasConflicts or 
+    if HasConflicts or
             ((length(Merged) /= length(A)) and (length(Merged) /= length(B))) ->
         Conflicts = conflicts;
     true ->
@@ -61,7 +61,7 @@
     no ->
         merge_one(Rest, {StartB, TreeB}, [{StartA, TreeA} | OutAcc], ConflictsAcc)
     end.
-    
+
 merge_at([], _Place, _Insert) ->
     no;
 merge_at([{Key, Value, SubTree}|Sibs], 0, {InsertKey, InsertValue, InsertSubTree}) ->
@@ -120,7 +120,7 @@
     ImpossibleKeys = [{KeyPos, KeyValue} || {KeyPos, KeyValue} <- SeachKeys, KeyPos < Start],
     Missing = find_missing_simple(Start, [{Key, Value, SubTree}], PossibleKeys),
     find_missing(RestTree, ImpossibleKeys ++ Missing).
-    
+
 find_missing_simple(_Pos, _Tree, []) ->
     [];
 find_missing_simple(_Pos, [], SeachKeys) ->
@@ -128,7 +128,7 @@
 find_missing_simple(Pos, [{Key, _, SubTree} | RestTree], SeachKeys) ->
     PossibleKeys = [{KeyPos, KeyValue} || {KeyPos, KeyValue} <- SeachKeys, KeyPos >= Pos],
     ImpossibleKeys = [{KeyPos, KeyValue} || {KeyPos, KeyValue} <- SeachKeys, KeyPos < Pos],
-    
+
     SrcKeys2 = PossibleKeys -- [{Pos, Key}],
     SrcKeys3 = find_missing_simple(Pos + 1, SubTree, SrcKeys2),
     ImpossibleKeys ++ find_missing_simple(Pos, RestTree, SrcKeys3).
@@ -145,15 +145,15 @@
         % this did match a key, remove both the node and the input key
         filter_leafs(Rest, FilteredKeys, FilteredAcc, [{Pos, LeafKey} | RemovedKeysAcc])
     end.
-    
+
 % Removes any branches from the tree whose leaf node(s) are in the Keys
 remove_leafs(Trees, Keys) ->
     % flatten each branch in a tree into a tree path
     Paths = get_all_leafs_full(Trees),
-    
+
     % filter out any that are in the keys list.
     {FilteredPaths, RemovedKeys} = filter_leafs(Paths, Keys, [], []),
-            
+
     % convert paths back to trees
     NewTree = lists:foldl(
         fun({PathPos, Path},TreeAcc) ->
@@ -170,7 +170,7 @@
 % are returned.
 get_key_leafs(Tree, Keys) ->
     get_key_leafs(Tree, Keys, []).
-    
+
 get_key_leafs(_, [], Acc) ->
     {Acc, []};
 get_key_leafs([], Keys, Acc) ->
@@ -178,14 +178,14 @@
 get_key_leafs([{Pos, Tree}|Rest], Keys, Acc) ->
     {Gotten, RemainingKeys} = get_key_leafs_simple(Pos, [Tree], Keys, []),
     get_key_leafs(Rest, RemainingKeys, Gotten ++ Acc).
-        
+
 get_key_leafs_simple(_Pos, _Tree, [], _KeyPathAcc) ->
     {[], []};
 get_key_leafs_simple(_Pos, [], KeysToGet, _KeyPathAcc) ->
     {[], KeysToGet};
 get_key_leafs_simple(Pos, [{Key, _Value, SubTree}=Tree | RestTree], KeysToGet, KeyPathAcc) ->
     case lists:delete({Pos, Key}, KeysToGet) of
-    KeysToGet -> % same list, key not found    
+    KeysToGet -> % same list, key not found
         {LeafsFound, KeysToGet2} = get_key_leafs_simple(Pos + 1, SubTree, KeysToGet, [Key | KeyPathAcc]),
         {RestLeafsFound, KeysRemaining} = get_key_leafs_simple(Pos, RestTree, KeysToGet2, KeyPathAcc),
         {LeafsFound ++ RestLeafsFound, KeysRemaining};
@@ -201,10 +201,10 @@
     {KeyPaths, KeysNotFound} = get_full_key_paths(Tree, KeysToGet),
     FixedResults = [ {Value, {Pos, [Key0 || {Key0, _} <- Path]}} || {Pos, [{_Key, Value}|_]=Path} <- KeyPaths],
     {FixedResults, KeysNotFound}.
-    
+
 get_full_key_paths(Tree, Keys) ->
     get_full_key_paths(Tree, Keys, []).
-    
+
 get_full_key_paths(_, [], Acc) ->
     {Acc, []};
 get_full_key_paths([], Keys, Acc) ->
@@ -212,8 +212,8 @@
 get_full_key_paths([{Pos, Tree}|Rest], Keys, Acc) ->
     {Gotten, RemainingKeys} = get_full_key_paths(Pos, [Tree], Keys, []),
     get_full_key_paths(Rest, RemainingKeys, Gotten ++ Acc).
-    
-    
+
+
 get_full_key_paths(_Pos, _Tree, [], _KeyPathAcc) ->
     {[], []};
 get_full_key_paths(_Pos, [], KeysToGet, _KeyPathAcc) ->
@@ -233,12 +233,12 @@
 
 get_all_leafs_full(Tree) ->
     get_all_leafs_full(Tree, []).
-    
+
 get_all_leafs_full([], Acc) ->
     Acc;
 get_all_leafs_full([{Pos, Tree} | Rest], Acc) ->
     get_all_leafs_full(Rest, get_all_leafs_full_simple(Pos, [Tree], []) ++ Acc).
-    
+
 get_all_leafs_full_simple(_Pos, [], _KeyPathAcc) ->
     [];
 get_all_leafs_full_simple(Pos, [{KeyId, Value, []} | RestTree], KeyPathAcc) ->
@@ -253,7 +253,7 @@
     Acc;
 get_all_leafs([{Pos, Tree}|Rest], Acc) ->
     get_all_leafs(Rest, get_all_leafs_simple(Pos, [Tree], []) ++ Acc).
-    
+
 get_all_leafs_simple(_Pos, [], _KeyPathAcc) ->
     [];
 get_all_leafs_simple(Pos, [{KeyId, Value, []} | RestTree], KeyPathAcc) ->
@@ -266,7 +266,7 @@
     0;
 count_leafs([{_Pos,Tree}|Rest]) ->
     count_leafs_simple([Tree]) + count_leafs(Rest).
-    
+
 count_leafs_simple([]) ->
     0;
 count_leafs_simple([{_Key, _Value, []} | RestTree]) ->
@@ -274,7 +274,7 @@
 count_leafs_simple([{_Key, _Value, SubTree} | RestTree]) ->
     count_leafs_simple(SubTree) + count_leafs_simple(RestTree).
 
-    
+
 map(_Fun, []) ->
     [];
 map(Fun, [{Pos, Tree}|Rest]) ->
@@ -287,7 +287,7 @@
     Value2 = Fun({Pos, Key}, Value),
     [{Key, Value2, map_simple(Fun, Pos + 1, SubTree)} | map_simple(Fun, Pos, RestTree)].
 
-    
+
 map_leafs(_Fun, []) ->
     [];
 map_leafs(Fun, [{Pos, Tree}|Rest]) ->
@@ -306,9 +306,9 @@
 stem(Trees, Limit) ->
     % flatten each branch in a tree into a tree path
     Paths = get_all_leafs_full(Trees),
-    
+
     Paths2 = [{Pos, lists:sublist(Path, Limit)} || {Pos, Path} <- Paths],
-    
+
     % convert paths back to trees
     lists:foldl(
         fun({PathPos, Path},TreeAcc) ->

Modified: couchdb/trunk/src/couchdb/couch_log.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_log.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_log.erl (original)
+++ couchdb/trunk/src/couchdb/couch_log.erl Mon Jul  6 00:33:50 2009
@@ -43,7 +43,7 @@
 
 init([]) ->
     % read config and register for configuration changes
-    
+
     % just stop if one of the config settings change. couch_server_sup
     % will restart us and then we will pick up the new settings.
     ok = couch_config:register(
@@ -52,7 +52,7 @@
         ("log", "level") ->
             ?MODULE:stop()
         end),
-    
+
     Filename = couch_config:get("log", "file", "couchdb.log"),
     Level = couch_config:get("log", "level", "info"),
 

Modified: couchdb/trunk/src/couchdb/couch_query_servers.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_query_servers.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_query_servers.erl (original)
+++ couchdb/trunk/src/couchdb/couch_query_servers.erl Mon Jul  6 00:33:50 2009
@@ -18,7 +18,7 @@
 -export([init/1, terminate/2, handle_call/3, handle_cast/2, handle_info/2,code_change/3,stop/0]).
 -export([start_doc_map/2, map_docs/2, stop_doc_map/1]).
 -export([reduce/3, rereduce/3,validate_doc_update/5]).
--export([render_doc_show/6, start_view_list/2, 
+-export([render_doc_show/6, start_view_list/2,
         render_list_head/4, render_list_row/3, render_list_tail/1]).
 % -export([test/0]).
 
@@ -42,7 +42,7 @@
     Results = lists:map(
         fun(Doc) ->
             Json = couch_doc:to_json_obj(Doc, []),
-            
+
             FunsResults = couch_os_process:prompt(Pid, [<<"map_doc">>, Json]),
             % the results are a json array of function map yields like this:
             % [FunResults1, FunResults2 ...]
@@ -90,7 +90,7 @@
             {ok, [Result]} = builtin_reduce(rereduce, [FunSrc], [[[], V] || V <- Values], []),
             Result;
         (FunSrc, Values) ->
-            [true, [Result]] = 
+            [true, [Result]] =
                 couch_os_process:prompt(Pid, [<<"rereduce">>, [FunSrc], Values]),
             Result
         end, RedSrcs, Grouped)
@@ -121,7 +121,7 @@
     {ok, []};
 os_reduce(Lang, OsRedSrcs, KVs) ->
     Pid = get_os_process(Lang),
-    OsResults = try couch_os_process:prompt(Pid, 
+    OsResults = try couch_os_process:prompt(Pid,
             [<<"reduce">>, OsRedSrcs, KVs]) of
         [true, Reductions] -> Reductions
     after
@@ -143,22 +143,22 @@
 
 builtin_sum_rows(KVs) ->
     lists:foldl(fun
-        ([_Key, Value], Acc) when is_number(Value) -> 
+        ([_Key, Value], Acc) when is_number(Value) ->
             Acc + Value;
-        (_Else, _Acc) -> 
+        (_Else, _Acc) ->
             throw({invalid_value, <<"builtin _sum function requires map values to be numbers">>})
     end, 0, KVs).
-    
+
 validate_doc_update(Lang, FunSrc, EditDoc, DiskDoc, Ctx) ->
     Pid = get_os_process(Lang),
     JsonEditDoc = couch_doc:to_json_obj(EditDoc, [revs]),
     JsonDiskDoc =
     if DiskDoc == nil ->
         null;
-    true -> 
+    true ->
         couch_doc:to_json_obj(DiskDoc, [revs])
     end,
-    try couch_os_process:prompt(Pid, 
+    try couch_os_process:prompt(Pid,
             [<<"validate">>, FunSrc, JsonEditDoc, JsonDiskDoc, Ctx]) of
     1 ->
         ok;
@@ -181,7 +181,7 @@
         {DocId, nil} -> {{append_docid(DocId, JsonReqIn)}, null};
         _ -> {{append_docid(DocId, JsonReqIn)}, couch_doc:to_json_obj(Doc, [revs])}
     end,
-    try couch_os_process:prompt(Pid, 
+    try couch_os_process:prompt(Pid,
         [<<"show">>, ShowSrc, JsonDoc, JsonReq]) of
     FormResp ->
         FormResp
@@ -209,18 +209,18 @@
 render_list_tail({Lang, Pid}) ->
     JsonResp = couch_os_process:prompt(Pid, [<<"list_end">>]),
     ok = ret_os_process(Lang, Pid),
-    JsonResp.    
-    
+    JsonResp.
+
 
 
 
 init([]) ->
-    
+
     % read config and register for configuration changes
-    
+
     % just stop if one of the config settings change. couch_server_sup
     % will restart us and then we will pick up the new settings.
-    
+
     ok = couch_config:register(
         fun("query_servers" ++ _, _) ->
             ?MODULE:stop()

Modified: couchdb/trunk/src/couchdb/couch_ref_counter.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_ref_counter.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_ref_counter.erl (original)
+++ couchdb/trunk/src/couchdb/couch_ref_counter.erl Mon Jul  6 00:33:50 2009
@@ -18,11 +18,11 @@
 
 start(ChildProcs) ->
     gen_server:start(couch_ref_counter, {self(), ChildProcs}, []).
-    
-    
+
+
 drop(RefCounterPid) ->
     drop(RefCounterPid, self()).
-    
+
 drop(RefCounterPid, Pid) ->
     gen_server:cast(RefCounterPid, {drop, Pid}).
 
@@ -42,7 +42,7 @@
     {
     referrers=dict:new() % a dict of each ref counting proc.
     }).
-    
+
 init({Pid, ChildProcs}) ->
     [link(ChildProc) || ChildProc <- ChildProcs],
     Referrers = dict:from_list([{Pid, {erlang:monitor(process, Pid), 1}}]),

Modified: couchdb/trunk/src/couchdb/couch_rep.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_rep.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep.erl Mon Jul  6 00:33:50 2009
@@ -12,7 +12,7 @@
 
 -module(couch_rep).
 -behaviour(gen_server).
--export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, 
+-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
     code_change/3]).
 
 -export([replicate/2]).
@@ -24,24 +24,24 @@
 -include("couch_db.hrl").
 -include("../ibrowse/ibrowse.hrl").
 
-%% @spec replicate(Source::binary(), Target::binary()) -> 
+%% @spec replicate(Source::binary(), Target::binary()) ->
 %%      {ok, Stats} | {error, Reason}
-%% @doc Triggers a replication.  Stats is a JSON Object with the following 
+%% @doc Triggers a replication.  Stats is a JSON Object with the following
 %%      keys: session_id (UUID), source_last_seq (integer), and history (array).
 %%      Each element of the history is an Object with keys start_time, end_time,
 %%      start_last_seq, end_last_seq, missing_checked, missing_found, docs_read,
 %%      and docs_written.
 %%
 %%      The supervisor will try to restart the replication in case of any error
-%%      other than shutdown.  Just call this function again to listen for the 
+%%      other than shutdown.  Just call this function again to listen for the
 %%      result of the retry.
 replicate(Source, Target) ->
-    
+
     {ok, HostName} = inet:gethostname(),
     RepId = couch_util:to_hex(
             erlang:md5(term_to_binary([HostName, Source, Target]))),
     Args = [?MODULE, [RepId, Source,Target], []],
-    
+
     Replicator = {RepId,
         {gen_server, start_link, Args},
         transient,
@@ -49,31 +49,31 @@
         worker,
         [?MODULE]
     },
-    
+
     Server = case supervisor:start_child(couch_rep_sup, Replicator) of
-        {ok, Pid} -> 
+        {ok, Pid} ->
             ?LOG_INFO("starting new replication ~p at ~p", [RepId, Pid]),
             Pid;
         {error, already_present} ->
             case supervisor:restart_child(couch_rep_sup, RepId) of
-                {ok, Pid} -> 
+                {ok, Pid} ->
                     ?LOG_INFO("starting replication ~p at ~p", [RepId, Pid]),
                     Pid;
-                {error, running} -> 
+                {error, running} ->
                     %% this error occurs if multiple replicators are racing
                     %% each other to start and somebody else won.  Just grab
                     %% the Pid by calling start_child again.
-                    {error, {already_started, Pid}} = 
+                    {error, {already_started, Pid}} =
                         supervisor:start_child(couch_rep_sup, Replicator),
                     ?LOG_INFO("replication ~p already running at ~p", [RepId, Pid]),
                     Pid
             end;
-        {error, {already_started, Pid}} -> 
+        {error, {already_started, Pid}} ->
             ?LOG_INFO("replication ~p already running at ~p", [RepId, Pid]),
             Pid
     end,
-    
-    case gen_server:call(Server, get_result, infinity) of 
+
+    case gen_server:call(Server, get_result, infinity) of
         retry -> replicate(Source, Target);
         Else -> Else
     end.
@@ -87,7 +87,7 @@
     headers
 }).
 
-    
+
 -record(state, {
     context,
     current_seq,
@@ -103,19 +103,19 @@
 
 init([RepId, Source, Target]) ->
     process_flag(trap_exit, true),
-    
+
     {ok, DbSrc, SrcName} = open_db(Source),
     {ok, DbTgt, TgtName} =  open_db(Target),
-    
+
     DocKey = ?l2b(?LOCAL_DOC_PREFIX ++ RepId),
-    
+
     {ok, InfoSrc} = get_db_info(DbSrc),
     {ok, InfoTgt} = get_db_info(DbTgt),
-    
+
     ReplicationStartTime = httpd_util:rfc1123_date(),
     SrcInstanceStartTime = proplists:get_value(instance_start_time, InfoSrc),
     TgtInstanceStartTime = proplists:get_value(instance_start_time, InfoTgt),
-    
+
     RepRecDocSrc =
     case open_doc(DbSrc, DocKey, []) of
     {ok, SrcDoc} ->
@@ -123,7 +123,7 @@
         SrcDoc;
     _ -> #doc{id=DocKey}
     end,
-    
+
     RepRecDocTgt =
     case open_doc(DbTgt, DocKey, []) of
     {ok, TgtDoc} ->
@@ -131,11 +131,11 @@
         TgtDoc;
     _ -> #doc{id=DocKey}
     end,
-    
+
     #doc{body={RepRecProps}} = RepRecDocSrc,
     #doc{body={RepRecPropsTgt}} = RepRecDocTgt,
-    
-    case proplists:get_value(<<"session_id">>, RepRecProps) == 
+
+    case proplists:get_value(<<"session_id">>, RepRecProps) ==
             proplists:get_value(<<"session_id">>, RepRecPropsTgt) of
     true ->
         % if the records have the same session id,
@@ -150,7 +150,7 @@
         OldSeqNum = 0,
         OldHistory = []
     end,
-    
+
     Context = [
         {start_seq, OldSeqNum},
         {history, OldHistory},
@@ -160,20 +160,20 @@
         {src_record, RepRecDocSrc},
         {tgt_record, RepRecDocTgt}
     ],
-    
+
     Stats = ets:new(replication_stats, [set, private]),
     ets:insert(Stats, {total_revs,0}),
     ets:insert(Stats, {missing_revs, 0}),
     ets:insert(Stats, {docs_read, 0}),
     ets:insert(Stats, {docs_written, 0}),
     ets:insert(Stats, {doc_write_failures, 0}),
-    
+
     couch_task_status:add_task("Replication", <<SrcName/binary, " -> ",
         TgtName/binary>>, "Starting"),
-    
+
     Parent = self(),
     Pid = spawn_link(fun() -> enum_docs_since(Parent,DbSrc,DbTgt,{OldSeqNum,0}) end),
-    
+
     State = #state{
         context = Context,
         current_seq = OldSeqNum,
@@ -182,7 +182,7 @@
         target = DbTgt,
         stats = Stats
     },
-    
+
     {ok, State}.
 handle_call(get_result, From, #state{listeners=L,done=true} = State) ->
     {stop, normal, State#state{listeners=[From|L]}};
@@ -200,14 +200,14 @@
     } = State,
 
     ets:update_counter(Stats, missing_revs, length(Revs)),
-    
+
     %% get document(s)
     {ok, DocResults} = open_doc_revs(Source, Id, Revs, [latest]),
     Docs = [RevDoc || {ok, RevDoc} <- DocResults],
     ets:update_counter(Stats, docs_read, length(Docs)),
-    
+
     %% save them (maybe in a buffer)
-    {NewBuffer, NewContext} = 
+    {NewBuffer, NewContext} =
     case should_flush(lists:flatlength([Docs|Buffer])) of
         true ->
             Docs2 = lists:flatten([Docs|Buffer]),
@@ -227,7 +227,7 @@
         false ->
             {[Docs | Buffer], Context}
     end,
-    
+
     {reply, ok, State#state{context=NewContext, docs_buffer=NewBuffer}};
 
 handle_call({fin, {LastSeq, RevsCount}}, {Pid,_}, #state{enum_pid=Pid} = State) ->
@@ -255,7 +255,7 @@
     Parent = self(),
     NewPid = spawn_link(fun() -> enum_docs_since(Parent,Src,Tgt,{Seq,0}) end),
     {noreply, State#state{enum_pid=NewPid}};
-    
+
 %% if any linked process dies, respawn the enumerator to get things going again
 handle_info({'EXIT', _From, normal}, State) ->
     {noreply, State};
@@ -277,7 +277,7 @@
         target = Target,
         stats = Stats
     } = State,
-    
+
     try update_docs(Target, lists:flatten(Buffer), [], replicated_changes) of
     {ok, Errors} ->
         dump_update_errors(Errors),
@@ -289,18 +289,18 @@
         ?LOG_ERROR("attachment request failed during final write", []),
         exit({internal_server_error, replication_link_failure})
     end,
-    
+
     couch_task_status:update("Finishing"),
-    
+
     {ok, NewRepHistory, _} = do_checkpoint(Source, Target, Context, Seq, Stats),
     ets:delete(Stats),
     close_db(Target),
-    
+
     [Original|Rest] = Listeners,
     gen_server:reply(Original, {ok, NewRepHistory}),
-    
-    %% maybe trigger another replication. If this replicator uses a local 
-    %% source Db, changes to that Db since we started will not be included in 
+
+    %% maybe trigger another replication. If this replicator uses a local
+    %% source Db, changes to that Db since we started will not be included in
     %% this pass.
     case up_to_date(Source, Seq) of
         true ->
@@ -319,9 +319,9 @@
         target = Target,
         stats = Stats
     } = State,
-    
+
     [gen_server:reply(L, {error, Reason}) || L <- Listeners],
-    
+
     ets:delete(Stats),
     close_db(Target),
     close_db(Source).
@@ -345,19 +345,19 @@
 
 attachment_loop(ReqId, Conn) ->
     couch_util:should_flush(),
-    receive 
+    receive
         {From, {set_req_id, NewId}} ->
             %% we learn the ReqId to listen for
             From ! {self(), {ok, NewId}},
             attachment_loop(NewId, Conn);
         {ibrowse_async_headers, ReqId, Status, Headers} ->
             %% we got header, give the controlling process a chance to react
-            receive 
-                {From, gimme_status} -> 
+            receive
+                {From, gimme_status} ->
                     %% send status/headers to controller
                     From ! {self(), {status, Status, Headers}},
                     receive
-                        {From, continue} -> 
+                        {From, continue} ->
                             %% normal case
                             attachment_loop(ReqId, Conn);
                         {From, fail} ->
@@ -382,7 +382,7 @@
             ?LOG_ERROR("streaming attachment failed with ~p", [Err]),
             catch ibrowse:stop_worker_process(Conn),
             exit(attachment_request_failed);
-        {ibrowse_async_response, ReqId, Data} -> 
+        {ibrowse_async_response, ReqId, Data} ->
             receive {From, gimme_data} -> From ! {self(), Data} end,
             attachment_loop(ReqId, Conn);
         {ibrowse_async_response_end, ReqId} ->
@@ -396,7 +396,7 @@
     Url = lists:flatten([DbUrl, url_encode(Id), "/", url_encode(?b2l(Name)),
         "?rev=", ?b2l(couch_doc:rev_to_str({Pos,RevId}))]),
     ?LOG_DEBUG("Attachment URL ~s", [Url]),
-    {ok, RcvFun} = make_attachment_stub_receiver(Url, Headers, Name, 
+    {ok, RcvFun} = make_attachment_stub_receiver(Url, Headers, Name,
         Type, Length),
     {Name, {Type, {RcvFun, Length}}}.
 
@@ -404,21 +404,21 @@
     make_attachment_stub_receiver(Url, Headers, Name, Type, Length, 10, 1000).
 
 make_attachment_stub_receiver(Url, _Headers, _Name, _Type, _Length, 0, _Pause) ->
-    ?LOG_ERROR("streaming attachment request failed after 10 retries: ~s", 
+    ?LOG_ERROR("streaming attachment request failed after 10 retries: ~s",
         [Url]),
     exit({attachment_request_failed, ?l2b(["failed to replicate ", Url])});
-    
+
 make_attachment_stub_receiver(Url, Headers, Name, Type, Length, Retries, Pause) ->
     %% start the process that receives attachment data from ibrowse
     #url{host=Host, port=Port} = ibrowse_lib:parse_url(Url),
     {ok, Conn} = ibrowse:spawn_link_worker_process(Host, Port),
     Pid = spawn_link(fun() -> attachment_loop(nil, Conn) end),
-    
+
     %% make the async request
     Opts = [{stream_to, Pid}, {response_format, binary}],
-    ReqId = 
+    ReqId =
     case ibrowse:send_req_direct(Conn, Url, Headers, get, [], Opts, infinity) of
-    {ibrowse_req_id, X} -> 
+    {ibrowse_req_id, X} ->
         X;
     {error, Reason} ->
         ?LOG_INFO("retrying couch_rep attachment request in ~p " ++
@@ -428,11 +428,11 @@
         make_attachment_stub_receiver(Url, Headers, Name, Type, Length,
             Retries-1, 2*Pause)
     end,
-    
+
     %% tell our receiver about the ReqId it needs to look for
     Pid ! {self(), {set_req_id, ReqId}},
-    receive 
-    {Pid, {ok, ReqId}} -> 
+    receive
+    {Pid, {ok, ReqId}} ->
         ok;
     {'EXIT', Pid, _Reason} ->
         catch ibrowse:stop_worker_process(Conn),
@@ -440,19 +440,19 @@
         make_attachment_stub_receiver(Url, Headers, Name, Type, Length,
             Retries-1, 2*Pause)
     end,
-    
+
     %% wait for headers to ensure that we have a 200 status code
     %% this is where we follow redirects etc
-    Pid ! {self(), gimme_status}, 
+    Pid ! {self(), gimme_status},
     receive
     {'EXIT', Pid, attachment_request_failed} ->
         catch ibrowse:stop_worker_process(Conn),
         make_attachment_stub_receiver(Url, Headers, Name, Type, Length,
             Retries-1, Pause);
-    {Pid, {status, StreamStatus, StreamHeaders}} -> 
+    {Pid, {status, StreamStatus, StreamHeaders}} ->
         ?LOG_DEBUG("streaming attachment Status ~p Headers ~p",
             [StreamStatus, StreamHeaders]),
-        
+
         ResponseCode = list_to_integer(StreamStatus),
         if
         ResponseCode >= 200, ResponseCode < 300 ->
@@ -461,10 +461,10 @@
             %% this function goes into the streaming attachment code.
             %% It gets executed by the replication gen_server, so it can't
             %% be the one to actually receive the ibrowse data.
-            {ok, fun() -> 
-                Pid ! {self(), gimme_data}, 
-                receive 
-                    {Pid, Data} -> 
+            {ok, fun() ->
+                Pid ! {self(), gimme_data},
+                receive
+                    {Pid, Data} ->
                         Data;
                     {'EXIT', Pid, attachment_request_failed} ->
                         throw(attachment_write_failed)
@@ -473,25 +473,25 @@
         ResponseCode >= 300, ResponseCode < 400 ->
             % follow the redirect
             Pid ! {self(), stop_ok},
-            RedirectUrl = mochiweb_headers:get_value("Location", 
+            RedirectUrl = mochiweb_headers:get_value("Location",
                 mochiweb_headers:make(StreamHeaders)),
             catch ibrowse:stop_worker_process(Conn),
             make_attachment_stub_receiver(RedirectUrl, Headers, Name, Type,
                 Length, Retries - 1, Pause);
-        ResponseCode >= 400, ResponseCode < 500 -> 
+        ResponseCode >= 400, ResponseCode < 500 ->
             % an error... log and fail
-            ?LOG_ERROR("streaming attachment failed with code ~p: ~s", 
+            ?LOG_ERROR("streaming attachment failed with code ~p: ~s",
                 [ResponseCode, Url]),
             Pid ! {self(), fail},
             exit(attachment_request_failed);
         ResponseCode == 500 ->
             % an error... log and retry
-            ?LOG_INFO("retrying couch_rep attachment request in ~p " ++ 
+            ?LOG_INFO("retrying couch_rep attachment request in ~p " ++
                 "seconds due to 500 response: ~s", [Pause/1000, Url]),
             Pid ! {self(), fail},
             catch ibrowse:stop_worker_process(Conn),
             timer:sleep(Pause),
-            make_attachment_stub_receiver(Url, Headers, Name, Type, Length, 
+            make_attachment_stub_receiver(Url, Headers, Name, Type, Length,
                 Retries - 1, 2*Pause)
         end
     end.
@@ -522,28 +522,28 @@
         {src_record, #doc{body={LastRepRecord}}=RepRecDocSrc},
         {tgt_record, RepRecDocTgt}
     ] = Context,
-    
+
     case NewSeqNum == StartSeqNum andalso OldHistory /= [] of
     true ->
         % nothing changed, don't record results
         {ok, {[{<<"no_changes">>, true} | LastRepRecord]}, Context};
     false ->
         % something changed, record results for incremental replication,
-        
+
         % commit changes to both src and tgt. The src because if changes
-        % we replicated are lost, we'll record the a seq number ahead 
+        % we replicated are lost, we'll record the a seq number ahead
         % of what was committed. If those changes are lost and the seq number
         % reverts to a previous committed value, we will skip future changes
         % when new doc updates are given our already replicated seq nums.
-        
+
         % commit the src async
         ParentPid = self(),
-        SrcCommitPid = spawn_link(fun() -> 
+        SrcCommitPid = spawn_link(fun() ->
                 ParentPid ! {self(), ensure_full_commit(Source)} end),
-                
+
         % commit tgt sync
         {ok, TgtInstanceStartTime2} = ensure_full_commit(Target),
-        
+
         SrcInstanceStartTime2 =
         receive
         {SrcCommitPid, {ok, Timestamp}} ->
@@ -551,7 +551,7 @@
         {'EXIT', SrcCommitPid, {http_request_failed, _}} ->
             exit(replication_link_failure)
         end,
-        
+
         RecordSeqNum =
         if SrcInstanceStartTime2 == SrcInstanceStartTime andalso
                 TgtInstanceStartTime2 == TgtInstanceStartTime ->
@@ -562,7 +562,7 @@
                 "replication is redone and documents reexamined.", []),
             StartSeqNum
         end,
-        
+
         NewHistoryEntry = {
             [{<<"start_time">>, list_to_binary(ReplicationStartTime)},
             {<<"end_time">>, list_to_binary(httpd_util:rfc1123_date())},
@@ -582,11 +582,11 @@
                   {<<"source_last_seq">>, RecordSeqNum},
                   {<<"history">>, HistEntries}]},
 
-        {ok, {SrcRevPos,SrcRevId}} = update_doc(Source, 
+        {ok, {SrcRevPos,SrcRevId}} = update_doc(Source,
                 RepRecDocSrc#doc{body=NewRepHistory}, []),
         {ok, {TgtRevPos,TgtRevId}} = update_doc(Target,
                 RepRecDocTgt#doc{body=NewRepHistory}, []),
-    
+
         NewContext = [
             {start_seq, StartSeqNum},
             {history, OldHistory},
@@ -596,9 +596,9 @@
             {src_record, RepRecDocSrc#doc{revs={SrcRevPos,[SrcRevId]}}},
             {tgt_record, RepRecDocTgt#doc{revs={TgtRevPos,[TgtRevId]}}}
         ],
-    
+
         {ok, NewRepHistory, NewContext}
-    
+
     end.
 
 do_http_request(Url, Action, Headers) ->
@@ -610,7 +610,7 @@
 do_http_request(Url, Action, Headers, Body, Retries, Pause) when is_binary(Url) ->
     do_http_request(?b2l(Url), Action, Headers, Body, Retries, Pause);
 do_http_request(Url, Action, _Headers, _JsonBody, 0, _Pause) ->
-    ?LOG_ERROR("couch_rep HTTP ~p request failed after 10 retries: ~s", 
+    ?LOG_ERROR("couch_rep HTTP ~p request failed after 10 retries: ~s",
         [Action, Url]),
     exit({http_request_failed, ?l2b(["failed to replicate ", Url])});
 do_http_request(Url, Action, Headers, JsonBody, Retries, Pause) ->
@@ -637,27 +637,27 @@
         ResponseCode >= 200, ResponseCode < 300 ->
             ?JSON_DECODE(ResponseBody);
         ResponseCode >= 300, ResponseCode < 400 ->
-            RedirectUrl = mochiweb_headers:get_value("Location", 
+            RedirectUrl = mochiweb_headers:get_value("Location",
                 mochiweb_headers:make(ResponseHeaders)),
             do_http_request(RedirectUrl, Action, Headers, JsonBody, Retries-1,
                 Pause);
-        ResponseCode >= 400, ResponseCode < 500 -> 
-            ?JSON_DECODE(ResponseBody);        
+        ResponseCode >= 400, ResponseCode < 500 ->
+            ?JSON_DECODE(ResponseBody);
         ResponseCode == 500 ->
-            ?LOG_INFO("retrying couch_rep HTTP ~p request in ~p seconds " ++ 
+            ?LOG_INFO("retrying couch_rep HTTP ~p request in ~p seconds " ++
                 "due to 500 error: ~s", [Action, Pause/1000, Url]),
             timer:sleep(Pause),
             do_http_request(Url, Action, Headers, JsonBody, Retries - 1, 2*Pause)
         end;
     {error, Reason} ->
-        ?LOG_INFO("retrying couch_rep HTTP ~p request in ~p seconds due to " ++ 
+        ?LOG_INFO("retrying couch_rep HTTP ~p request in ~p seconds due to " ++
             "{error, ~p}: ~s", [Action, Pause/1000, Reason, Url]),
         timer:sleep(Pause),
         do_http_request(Url, Action, Headers, JsonBody, Retries - 1, 2*Pause)
     end.
 
 ensure_full_commit(#http_db{uri=DbUrl, headers=Headers}) ->
-    {ResultProps} = do_http_request(DbUrl ++ "_ensure_full_commit", post, 
+    {ResultProps} = do_http_request(DbUrl ++ "_ensure_full_commit", post,
         Headers, true),
     true = proplists:get_value(<<"ok">>, ResultProps),
     {ok, proplists:get_value(<<"instance_start_time">>, ResultProps)};
@@ -672,22 +672,22 @@
         SrcRevsList = lists:map(fun(#doc_info{id=Id,revs=RevInfos}) ->
             SrcRevs = [Rev || #rev_info{rev=Rev} <- RevInfos],
             {Id, SrcRevs}
-        end, DocInfoList),        
+        end, DocInfoList),
         {ok, MissingRevs} = get_missing_revs(DbTarget, SrcRevsList),
-        
+
         %% do we need to check for success here?
-        [gen_server:call(Pid, {replicate_doc, Info}, infinity) 
+        [gen_server:call(Pid, {replicate_doc, Info}, infinity)
             || Info <- MissingRevs ],
-        
+
         #doc_info{high_seq=LastSeq} = lists:last(DocInfoList),
         RevsCount2 = RevsCount + length(SrcRevsList),
         gen_server:cast(Pid, {increment_update_seq, LastSeq}),
-        
+
         enum_docs_since(Pid, DbSource, DbTarget, {LastSeq, RevsCount2})
     end.
 
 
-            
+
 get_db_info(#http_db{uri=DbUrl, headers=Headers}) ->
     {DbProps} = do_http_request(DbUrl, get, Headers),
     {ok, [{list_to_atom(?b2l(K)), V} || {K,V} <- DbProps]};
@@ -695,14 +695,14 @@
     couch_db:get_db_info(Db).
 
 get_doc_info_list(#http_db{uri=DbUrl, headers=Headers}, StartSeq) ->
-    Url = DbUrl ++ "_all_docs_by_seq?limit=100&startkey=" 
+    Url = DbUrl ++ "_all_docs_by_seq?limit=100&startkey="
         ++ integer_to_list(StartSeq),
     {Results} = do_http_request(Url, get, Headers),
     lists:map(fun({RowInfoList}) ->
         {RowValueProps} = proplists:get_value(<<"value">>, RowInfoList),
         Seq = proplists:get_value(<<"key">>, RowInfoList),
-        Revs = 
-            [#rev_info{rev=couch_doc:parse_rev(proplists:get_value(<<"rev">>, RowValueProps)), deleted = proplists:get_value(<<"deleted">>, RowValueProps, false)} | 
+        Revs =
+            [#rev_info{rev=couch_doc:parse_rev(proplists:get_value(<<"rev">>, RowValueProps)), deleted = proplists:get_value(<<"deleted">>, RowValueProps, false)} |
                 [#rev_info{rev=Rev,deleted=false} || Rev <- couch_doc:parse_revs(proplists:get_value(<<"conflicts">>, RowValueProps, []))] ++
                 [#rev_info{rev=Rev,deleted=true} || Rev <- couch_doc:parse_revs(proplists:get_value(<<"deleted_conflicts">>, RowValueProps, []))]],
         #doc_info{
@@ -712,11 +712,11 @@
         }
     end, proplists:get_value(<<"rows">>, Results));
 get_doc_info_list(DbSource, StartSeq) ->
-    {ok, {_Count, DocInfoList}} = couch_db:enum_docs_since(DbSource, StartSeq, 
+    {ok, {_Count, DocInfoList}} = couch_db:enum_docs_since(DbSource, StartSeq,
     fun (_, _, {100, DocInfoList}) ->
             {stop, {100, DocInfoList}};
-        (DocInfo, _, {Count, DocInfoList}) -> 
-            {ok, {Count+1, [DocInfo|DocInfoList]}} 
+        (DocInfo, _, {Count, DocInfoList}) ->
+            {ok, {Count+1, [DocInfo|DocInfoList]}}
     end, {0, []}),
     lists:reverse(DocInfoList).
 
@@ -742,14 +742,14 @@
 open_doc(Db, DocId, Options) ->
     couch_db:open_doc(Db, DocId, Options).
 
-open_doc_revs(#http_db{uri=DbUrl, headers=Headers} = DbS, DocId, Revs0, 
+open_doc_revs(#http_db{uri=DbUrl, headers=Headers} = DbS, DocId, Revs0,
         [latest]) ->
     Revs = couch_doc:rev_to_strs(Revs0),
     BaseUrl = DbUrl ++ url_encode(DocId) ++ "?revs=true&latest=true",
-    
+
     %% MochiWeb expects URLs < 8KB long, so maybe split into multiple requests
     MaxN = trunc((8192 - length(BaseUrl))/14),
-    
+
     JsonResults = case length(Revs) > MaxN of
     false ->
         Url = ?l2b(BaseUrl ++ "&open_revs=" ++ ?JSON_ENCODE(Revs)),
@@ -766,7 +766,7 @@
         Acc ++ do_http_request(?l2b(BaseUrl ++ "&open_revs=" ++
             ?JSON_ENCODE(lists:reverse(Rest))), get, Headers)
     end,
-    
+
     Results =
     lists:map(
         fun({[{<<"missing">>, Rev}]}) ->
@@ -791,7 +791,7 @@
 should_flush(_DocCount) ->
     MeAndMyLinks = [self()|
         [P || P <- element(2,process_info(self(),links)), is_pid(P)]],
-    
+
     case length(MeAndMyLinks)/2 > ?BUFFER_NATTACHMENTS of
     true -> true;
     false ->

Modified: couchdb/trunk/src/couchdb/couch_server.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_server.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_server.erl (original)
+++ couchdb/trunk/src/couchdb/couch_server.erl Mon Jul  6 00:33:50 2009
@@ -42,7 +42,7 @@
 restart() ->
     stop(),
     start().
-    
+
 stop() ->
     couch_server_sup:stop().
 
@@ -127,7 +127,7 @@
 
 init([]) ->
     % read config and register for configuration changes
-    
+
     % just stop if one of the config settings change. couch_server_sup
     % will restart us and then we will pick up the new settings.
 
@@ -292,7 +292,7 @@
     case check_dbname(Server, DbNameList) of
     ok ->
         FullFilepath = get_full_filename(Server, DbNameList),
-        Server2 = 
+        Server2 =
         case ets:lookup(couch_dbs_by_name, DbName) of
         [] -> Server;
         [{_, {Pid, LruTime}}] ->
@@ -303,11 +303,11 @@
             true = ets:delete(couch_dbs_by_lru, LruTime),
             Server#server{dbs_open=Server#server.dbs_open - 1}
         end,
-        
+
         %% Delete any leftover .compact files.  If we don't do this a subsequent
         %% request for this DB will try to open the .compact file and use it.
         file:delete(FullFilepath ++ ".compact"),
-        
+
         case file:delete(FullFilepath) of
         ok ->
             couch_db_update_notifier:notify({deleted, DbName}),
@@ -326,7 +326,7 @@
 
 code_change(_OldVsn, State, _Extra) ->
     {ok, State}.
-    
+
 handle_info({'EXIT', _Pid, config_change}, _Server) ->
     exit(kill);
 handle_info({'EXIT', Pid, _Reason}, #server{dbs_open=DbsOpen}=Server) ->

Modified: couchdb/trunk/src/couchdb/couch_server_sup.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_server_sup.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_server_sup.erl (original)
+++ couchdb/trunk/src/couchdb/couch_server_sup.erl Mon Jul  6 00:33:50 2009
@@ -83,7 +83,7 @@
     ok = couch_util:start_driver(LibDir),
 
     BaseChildSpecs =
-    {{one_for_all, 10, 3600}, 
+    {{one_for_all, 10, 3600},
         [{couch_config,
             {couch_server_sup, couch_config_start_link_wrapper, [IniFiles, ConfigPid]},
             permanent,
@@ -130,7 +130,7 @@
 
 start_primary_services() ->
     supervisor:start_link({local, couch_primary_services}, couch_server_sup,
-        {{one_for_one, 10, 3600}, 
+        {{one_for_one, 10, 3600},
             [{couch_log,
                 {couch_log, start_link, []},
                 permanent,
@@ -168,7 +168,7 @@
     DaemonChildSpecs = [
         begin
             {ok, {Module, Fun, Args}} = couch_util:parse_term(SpecStr),
-            
+
             {list_to_atom(Name),
                 {Module, Fun, Args},
                 permanent,

Modified: couchdb/trunk/src/couchdb/couch_stats_aggregator.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_stats_aggregator.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_stats_aggregator.erl (original)
+++ couchdb/trunk/src/couchdb/couch_stats_aggregator.erl Mon Jul  6 00:33:50 2009
@@ -18,7 +18,7 @@
 -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
         terminate/2, code_change/3]).
 
--export([start/0, stop/0, 
+-export([start/0, stop/0,
          get/1, get/2, get_json/1, get_json/2, all/0,
          time_passed/0, clear_aggregates/1]).
 
@@ -34,7 +34,7 @@
 
 start() ->
     gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
-    
+
 stop() ->
     gen_server:call(?MODULE, stop).
 
@@ -47,18 +47,18 @@
     gen_server:call(?MODULE, {get_json, Key}).
 get_json(Key, Time) ->
     gen_server:call(?MODULE, {get_json, Key, Time}).
-    
+
 time_passed() ->
     gen_server:call(?MODULE, time_passed).
 
-clear_aggregates(Time) -> 
+clear_aggregates(Time) ->
     gen_server:call(?MODULE, {clear_aggregates, Time}).
 
 all() ->
     gen_server:call(?MODULE, all).
 
 % GEN_SERVER
-    
+
 init(_) ->
     ets:new(?MODULE, [named_table, set, protected]),
     init_timers(),
@@ -86,13 +86,13 @@
     % the foldls below could probably be refactored into a less code-duping form
 
     % update aggregates on incremental counters
-    NextState = lists:foldl(fun(Counter, State) -> 
+    NextState = lists:foldl(fun(Counter, State) ->
         {Key, Value} = Counter,
         update_aggregates_loop(Key, Value, State, incremental)
     end, OldState, ?COLLECTOR:all(incremental)),
 
     % update aggregates on absolute value counters
-    NewState = lists:foldl(fun(Counter, State) -> 
+    NewState = lists:foldl(fun(Counter, State) ->
         {Key, Value} = Counter,
         % clear the counter, we've got the important bits in State
         ?COLLECTOR:clear(Key),
@@ -117,7 +117,7 @@
 % Stats = [{Key, TimesProplist}]
 % TimesProplist = [{Time, Aggrgates}]
 % Aggregates = #aggregates{}
-% 
+%
 % [
 %  {Key, [
 %             {TimeA, #aggregates{}},
@@ -126,7 +126,7 @@
 %             {TimeD, #aggregates{}}
 %        ]
 %  },
-%  
+%
 % ]
 
 %% clear the aggregats record for a specific Time = 60 | 300 | 900
@@ -134,7 +134,7 @@
     NewStats = lists:map(fun({Key, TimesProplist}) ->
         {Key, case proplists:lookup(Time, TimesProplist) of
             % do have stats for this key, if we don't, return Stat unmodified
-            none -> 
+            none ->
                 TimesProplist;
             % there are stats, let's unset the Time one
             {_Time, _Stat} ->
@@ -177,12 +177,12 @@
     %               {'900',{aggregates,1,1,1,0,0,1,1}}]}]
     [{_Key, StatsList}] = case proplists:lookup(Key, AllStats) of
         none -> [{Key, [
-                {'0', empty}, 
+                {'0', empty},
                 {'60', empty},
                 {'300', empty},
                 {'900', empty}
              ]}];
-        AllStatsMatch -> 
+        AllStatsMatch ->
         [AllStatsMatch]
     end,
 
@@ -236,7 +236,7 @@
                 incremental -> Value - Current;
                 absolute -> Value
             end,
-                % Knuth, The Art of Computer Programming, vol. 2, p. 232. 
+                % Knuth, The Art of Computer Programming, vol. 2, p. 232.
                 NewCount = Count + 1,
                 NewMean = Mean + (NewValue - Mean) / NewCount, % NewCount is never 0.
                 NewVariance = Variance + (NewValue - Mean) * (NewValue - NewMean),
@@ -288,29 +288,29 @@
 
 init_descriptions() ->
 
-    % ets is probably overkill here, but I didn't manage to keep the 
+    % ets is probably overkill here, but I didn't manage to keep the
     % descriptions in the gen_server state. Which means there is probably
     % a bug in one of the handle_call() functions most likely the one that
     % handles the time_passed message. But don't tell anyone, the math is
     % correct :) -- Jan
 
 
-    % Style guide for descriptions: Start with a lowercase letter & do not add 
+    % Style guide for descriptions: Start with a lowercase letter & do not add
     % a trailing full-stop / period.
-    
+
     % please keep this in alphabetical order
     ets:insert(?MODULE, {{couchdb, database_writes}, <<"number of times a database was changed">>}),
     ets:insert(?MODULE, {{couchdb, database_reads}, <<"number of times a document was read from a database">>}),
     ets:insert(?MODULE, {{couchdb, open_databases}, <<"number of open databases">>}),
     ets:insert(?MODULE, {{couchdb, open_os_files}, <<"number of file descriptors CouchDB has open">>}),
     ets:insert(?MODULE, {{couchdb, request_time}, <<"length of a request inside CouchDB without MochiWeb">>}),
-    
+
     ets:insert(?MODULE, {{httpd, bulk_requests}, <<"number of bulk requests">>}),
     ets:insert(?MODULE, {{httpd, requests}, <<"number of HTTP requests">>}),
     ets:insert(?MODULE, {{httpd, temporary_view_reads}, <<"number of temporary view reads">>}),
     ets:insert(?MODULE, {{httpd, view_reads}, <<"number of view reads">>}),
     ets:insert(?MODULE, {{httpd, clients_requesting_changes}, <<"Number of clients currently requesting continuous _changes">>}),
-    
+
     ets:insert(?MODULE, {{httpd_request_methods, 'COPY'}, <<"number of HTTP COPY requests">>}),
     ets:insert(?MODULE, {{httpd_request_methods, 'DELETE'}, <<"number of HTTP DELETE requests">>}),
     ets:insert(?MODULE, {{httpd_request_methods, 'GET'}, <<"number of HTTP GET requests">>}),
@@ -318,7 +318,7 @@
     ets:insert(?MODULE, {{httpd_request_methods, 'MOVE'}, <<"number of HTTP MOVE requests">>}),
     ets:insert(?MODULE, {{httpd_request_methods, 'POST'}, <<"number of HTTP POST requests">>}),
     ets:insert(?MODULE, {{httpd_request_methods, 'PUT'}, <<"number of HTTP PUT requests">>}),
-    
+
     ets:insert(?MODULE, {{httpd_status_codes, '200'}, <<"number of HTTP 200 OK responses">>}),
     ets:insert(?MODULE, {{httpd_status_codes, '201'}, <<"number of HTTP 201 Created responses">>}),
     ets:insert(?MODULE, {{httpd_status_codes, '202'}, <<"number of HTTP 202 Accepted responses">>}),
@@ -338,12 +338,12 @@
 % Timer
 
 init_timers() ->
-    
+
     % OTP docs on timer: http://erlang.org/doc/man/timer.html
     %   start() -> ok
-    %   Starts the timer server. Normally, the server does not need to be 
-    %   started explicitly. It is started dynamically if it is needed. This is 
-    %   useful during development, but in a target system the server should be 
+    %   Starts the timer server. Normally, the server does not need to be
+    %   started explicitly. It is started dynamically if it is needed. This is
+    %   useful during development, but in a target system the server should be
     %   started explicitly. Use configuration parameters for kernel for this.
     %
     % TODO: Add timer_start to kernel start options.
@@ -361,7 +361,7 @@
 
 
 % Unused gen_server behaviour API functions that we need to declare.
-  
+
 %% @doc Unused
 handle_cast(foo, State) ->
     {noreply, State}.

Modified: couchdb/trunk/src/couchdb/couch_stats_collector.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_stats_collector.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_stats_collector.erl (original)
+++ couchdb/trunk/src/couchdb/couch_stats_collector.erl Mon Jul  6 00:33:50 2009
@@ -22,7 +22,7 @@
         terminate/2, code_change/3]).
 
 
--export([start/0, stop/0, get/1, 
+-export([start/0, stop/0, get/1,
         increment/1, decrement/1,
         track_process_count/1, track_process_count/2,
         record/2, clear/1,
@@ -38,15 +38,15 @@
 
 start() ->
     gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
-    
+
 stop() ->
     gen_server:call(?MODULE, stop).
 
 get(Key) ->
     case ets:lookup(?HIT_COUNTER_TABLE, Key) of
-        [] -> 
+        [] ->
             case ets:lookup(?ABSOLUTE_VALUE_COUNTER_TABLE, Key) of
-                [] -> 
+                [] ->
                     0;
                 Result2 -> extract_value_from_ets_result(Key, Result2)
             end;
@@ -62,7 +62,7 @@
             ok;
         _ -> ok
     end.
-    
+
 decrement(Key) ->
     case catch ets:update_counter(?HIT_COUNTER_TABLE, Key, -1) of
         {'EXIT', {badarg, _}} ->
@@ -70,7 +70,7 @@
             ok;
         _ -> ok
     end.
-    
+
 record(Key, Value) ->
     ets:insert(?ABSOLUTE_VALUE_COUNTER_TABLE, {Key, Value}).
 
@@ -78,7 +78,7 @@
     true = ets:delete(?ABSOLUTE_VALUE_COUNTER_TABLE, Key).
 
 all() ->
-    lists:append(ets:tab2list(?HIT_COUNTER_TABLE), 
+    lists:append(ets:tab2list(?HIT_COUNTER_TABLE),
         ets:tab2list(?ABSOLUTE_VALUE_COUNTER_TABLE)).
 
 all(Type) ->
@@ -123,7 +123,7 @@
 
 
 % Unused gen_server behaviour API functions that we need to declare.
-  
+
 %% @doc Unused
 handle_cast(foo, State) ->
     {noreply, State}.

Modified: couchdb/trunk/src/couchdb/couch_stream.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_stream.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_stream.erl (original)
+++ couchdb/trunk/src/couchdb/couch_stream.erl Mon Jul  6 00:33:50 2009
@@ -67,7 +67,7 @@
         end, ok),
     close(Dest).
 
-% 09 UPGRADE CODE    
+% 09 UPGRADE CODE
 old_foldl(_Fd, null, 0, _Fun, Acc) ->
     Acc;
 old_foldl(Fd, OldPointer, Len, Fun, Acc) when is_tuple(OldPointer)->
@@ -119,7 +119,7 @@
         written_pointers = Written,
         buffer_len = BufferLen,
         buffer_list = Buffer} = Stream,
-    
+
     case Buffer of
     [] ->
         Result = {lists:reverse(Written), WrittenLen};
@@ -137,7 +137,7 @@
 
 handle_info(_Info, State) ->
     {noreply, State}.
-    
+
 
 
 % 09 UPGRADE CODE

Modified: couchdb/trunk/src/couchdb/couch_task_status.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_task_status.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_task_status.erl (original)
+++ couchdb/trunk/src/couchdb/couch_task_status.erl Mon Jul  6 00:33:50 2009
@@ -59,7 +59,7 @@
 
 update(StatusText) ->
     update("~s", [StatusText]).
-    
+
 update(Format, Data) ->
     {LastUpdateTime, Frequency} = get(task_status_update),
     case timer:now_diff(Now = now(), LastUpdateTime) >= Frequency of

Modified: couchdb/trunk/src/couchdb/couch_util.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_util.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_util.erl (original)
+++ couchdb/trunk/src/couchdb/couch_util.erl Mon Jul  6 00:33:50 2009
@@ -56,7 +56,7 @@
 
 new_uuid() ->
     list_to_binary(to_hex(crypto:rand_bytes(16))).
-    
+
 to_hex([]) ->
     [];
 to_hex(Bin) when is_binary(Bin) ->
@@ -73,7 +73,7 @@
 parse_term(List) ->
     {ok, Tokens, _} = erl_scan:string(List ++ "."),
     erl_parse:parse_term(Tokens).
-    
+
 
 % returns a random integer
 rand32() ->
@@ -193,15 +193,15 @@
 
 should_flush() ->
     should_flush(?FLUSH_MAX_MEM).
-    
+
 should_flush(MemThreshHold) ->
     {memory, ProcMem} = process_info(self(), memory),
-    BinMem = lists:foldl(fun({_Id, Size, _NRefs}, Acc) -> Size+Acc end, 
+    BinMem = lists:foldl(fun({_Id, Size, _NRefs}, Acc) -> Size+Acc end,
         0, element(2,process_info(self(), binary))),
     if ProcMem+BinMem > 2*MemThreshHold ->
         garbage_collect(),
         {memory, ProcMem2} = process_info(self(), memory),
-        BinMem2 = lists:foldl(fun({_Id, Size, _NRefs}, Acc) -> Size+Acc end, 
+        BinMem2 = lists:foldl(fun({_Id, Size, _NRefs}, Acc) -> Size+Acc end,
             0, element(2,process_info(self(), binary))),
         if ProcMem2+BinMem2 > MemThreshHold ->
             true;
@@ -230,7 +230,7 @@
     encodeBase64(list_to_binary(Bs), <<>>);
 encodeBase64(Bs) ->
     encodeBase64(Bs, <<>>).
-    
+
 encodeBase64(<<B:3/binary, Bs/binary>>, Acc) ->
     <<C1:6, C2:6, C3:6, C4:6>> = B,
     encodeBase64(Bs, <<Acc/binary, (enc(C1)), (enc(C2)), (enc(C3)), (enc(C4))>>);

Modified: couchdb/trunk/src/couchdb/couch_view.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_view.erl?rev=791350&r1=791349&r2=791350&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_view.erl Mon Jul  6 00:33:50 2009
@@ -24,14 +24,14 @@
 
 -record(server,{
     root_dir = []}).
-    
+
 start_link() ->
     gen_server:start_link({local, couch_view}, couch_view, [], []).
 
 get_temp_updater(DbName, Language, DesignOptions, MapSrc, RedSrc) ->
     % make temp group
     % do we need to close this db?
-    {ok, _Db, Group} = 
+    {ok, _Db, Group} =
         couch_view_group:open_temp_group(DbName, Language, DesignOptions, MapSrc, RedSrc),
     case gen_server:call(couch_view, {get_group_server, DbName, Group}) of
     {ok, Pid} ->
@@ -44,7 +44,7 @@
     % get signature for group
     case couch_view_group:open_db_group(DbName, GroupId) of
     % do we need to close this db?
-    {ok, _Db, Group} ->        
+    {ok, _Db, Group} ->
         case gen_server:call(couch_view, {get_group_server, DbName, Group}) of
         {ok, Pid} ->
             Pid;
@@ -54,7 +54,7 @@
     Error ->
         throw(Error)
     end.
-    
+
 get_group(Db, GroupId, Stale) ->
     MinUpdateSeq = case Stale of
     ok -> 0;
@@ -73,23 +73,23 @@
     couch_view_group:request_group_info(
         get_group_server(couch_db:name(Db), GroupId)).
 
-cleanup_index_files(Db) -> 
+cleanup_index_files(Db) ->
     % load all ddocs
     {ok, DesignDocs} = couch_db:get_design_docs(Db),
-    
+
     % make unique list of group sigs
     Sigs = lists:map(fun(#doc{id = GroupId} = DDoc) ->
         {ok, Info} = get_group_info(Db, GroupId),
         ?b2l(proplists:get_value(signature, Info))
     end, [DD||DD <- DesignDocs, DD#doc.deleted == false]),
-    
+
     FileList = list_index_files(Db),
-    
+
     % regex that matches all ddocs
     RegExp = "("++ string:join(Sigs, "|") ++")",
 
     % filter out the ones in use
-    DeleteFiles = lists:filter(fun(FilePath) -> 
+    DeleteFiles = lists:filter(fun(FilePath) ->
             regexp:first_match(FilePath, RegExp)==nomatch
         end, FileList),
     % delete unused files
@@ -108,7 +108,7 @@
     {ok, Count}.
 
 get_temp_reduce_view(Db, Language, DesignOptions, MapSrc, RedSrc) ->
-    {ok, #group{views=[View]}=Group} = 
+    {ok, #group{views=[View]}=Group} =
         get_temp_group(Db, Language, DesignOptions, MapSrc, RedSrc),
     {ok, {temp_reduce, View}, Group}.
 
@@ -161,7 +161,7 @@
     couch_btree:fold_reduce(Bt, Dir, StartKey, EndKey, GroupFun,
             WrapperFun, Acc);
 
-fold_reduce({reduce, NthRed, Lang, #view{btree=Bt, reduce_funs=RedFuns}}, Dir, StartKey, EndKey, GroupFun, Fun, Acc) ->    
+fold_reduce({reduce, NthRed, Lang, #view{btree=Bt, reduce_funs=RedFuns}}, Dir, StartKey, EndKey, GroupFun, Fun, Acc) ->
     PreResultPadding = lists:duplicate(NthRed - 1, []),
     PostResultPadding = lists:duplicate(length(RedFuns) - NthRed, []),
     {_Name, FunSrc} = lists:nth(NthRed,RedFuns),
@@ -180,7 +180,7 @@
         end,
     couch_btree:fold_reduce(Bt, Dir, StartKey, EndKey, GroupFun,
             WrapperFun, Acc).
-        
+
 get_key_pos(_Key, [], _N) ->
     0;
 get_key_pos(Key, [{Key1,_Value}|_], N) when Key == Key1 ->
@@ -215,7 +215,7 @@
     end.
 
 reduce_to_count(Reductions) ->
-    {Count, _} = 
+    {Count, _} =
     couch_btree:final_reduce(
         fun(reduce, KVs) ->
             Count = lists:sum(
@@ -226,9 +226,9 @@
             {lists:sum([Count0 || {Count0, _} <- Reds]), []}
         end, Reductions),
     Count.
-                
 
-    
+
+
 fold_fun(_Fun, [], _, Acc) ->
     {ok, Acc};
 fold_fun(Fun, [KV|Rest], {KVReds, Reds}, Acc) ->
@@ -258,7 +258,7 @@
         fun("couchdb", "view_index_dir")->
             exit(Self, config_change)
         end),
-        
+
     couch_db_update_notifier:start_link(
         fun({deleted, DbName}) ->
             gen_server:cast(couch_view, {reset_indexes, DbName});
@@ -279,11 +279,11 @@
     ok.
 
 
-handle_call({get_group_server, DbName, 
+handle_call({get_group_server, DbName,
     #group{name=GroupId,sig=Sig}=Group}, _From, #server{root_dir=Root}=Server) ->
     case ets:lookup(group_servers_by_sig, {DbName, Sig}) of
     [] ->
-        ?LOG_DEBUG("Spawning new group server for view group ~s in database ~s.", 
+        ?LOG_DEBUG("Spawning new group server for view group ~s in database ~s.",
             [GroupId, DbName]),
         case (catch couch_view_group:start_link({Root, DbName, Group})) of
         {ok, NewPid} ->
@@ -325,12 +325,12 @@
         delete_from_ets(FromPid, DbName, GroupId)
     end,
     {noreply, Server}.
-    
+
 add_to_ets(Pid, DbName, Sig) ->
     true = ets:insert(couch_groups_by_updater, {Pid, {DbName, Sig}}),
     true = ets:insert(group_servers_by_sig, {{DbName, Sig}, Pid}),
     true = ets:insert(couch_groups_by_db, {DbName, Sig}).
-    
+
 delete_from_ets(Pid, DbName, Sig) ->
     true = ets:delete(couch_groups_by_updater, Pid),
     true = ets:delete(group_servers_by_sig, {DbName, Sig}),
@@ -356,7 +356,7 @@
                     ok = nuke_dir(Full)
                 end
             end,
-            Files),    
+            Files),
         ok = file:del_dir(Dir)
     end.
 
@@ -400,7 +400,7 @@
   less_list(A, B);
 less_same_type(A, B) ->
     A < B.
-	
+
 less_props([], [_|_]) ->
     true;
 less_props(_, []) ->



Mime
View raw message