Skip to content

Commit

Permalink
Fix potential module collision
Browse files Browse the repository at this point in the history
  • Loading branch information
khueue committed Sep 3, 2012
1 parent 000f57c commit f585502
Show file tree
Hide file tree
Showing 24 changed files with 65 additions and 106 deletions.
3 changes: 1 addition & 2 deletions load.pl
Expand Up @@ -44,7 +44,6 @@


prolongo_configure_load_paths :- prolongo_configure_load_paths :-
prolog_load_context(directory, Root), % Available only during compilation. prolog_load_context(directory, Root), % Available only during compilation.
prolongo_configure_path(Root, 'src/misc', misc),
prolongo_configure_path(Root, 'src', mongo). prolongo_configure_path(Root, 'src', mongo).


prolongo_configure_path(PathPrefix, PathSuffix, Name) :- prolongo_configure_path(PathPrefix, PathSuffix, Name) :-
Expand All @@ -60,7 +59,7 @@
% but I haven't noticed much difference. % but I haven't noticed much difference.
% :- use_module(library(apply_macros)). % :- use_module(library(apply_macros)).


:- include(misc(common)). :- include(mongo(include/common)).


prolongo_load_project_modules :- prolongo_load_project_modules :-
use_module(library(pldoc), []), % Load first to enable comment processing. use_module(library(pldoc), []), % Load first to enable comment processing.
Expand Down
File renamed without changes.
67 changes: 0 additions & 67 deletions src/misc/util.pl

This file was deleted.

3 changes: 1 addition & 2 deletions src/mongo.pl
Expand Up @@ -25,14 +25,13 @@
mongo_command mongo_command
]). ]).


:- include(misc(common)). :- include(include/common).


% Internal modules. % Internal modules.
:- use_module(mongo_socket, []). :- use_module(mongo_socket, []).
:- use_module(mongo_util, []). :- use_module(mongo_util, []).
:- use_module(mongo_bytes, []). :- use_module(mongo_bytes, []).
:- use_module(mongo_test_helper, []). :- use_module(mongo_test_helper, []).
:- use_module(misc(util), []).
:- use_module(bson(bson), []). :- use_module(bson(bson), []).


%% version(?Version) is semidet. %% version(?Version) is semidet.
Expand Down
2 changes: 1 addition & 1 deletion src/mongo_bytes.pl
Expand Up @@ -14,7 +14,7 @@
count_bytes_and_set_length/1 count_bytes_and_set_length/1
]). ]).


:- include(misc(common)). :- include(include/common).


int32s([]) --> []. int32s([]) --> [].
int32s([Int|Ints]) --> int32s([Int|Ints]) -->
Expand Down
6 changes: 3 additions & 3 deletions src/mongo_collection.pl
Expand Up @@ -10,7 +10,7 @@
collection_connection/2 collection_connection/2
]). ]).


:- include(misc(common)). :- include(include/common).


%% new_collection(+Database, +CollectionName, -Collection) is det. %% new_collection(+Database, +CollectionName, -Collection) is det.
% %
Expand All @@ -28,7 +28,7 @@
% True if Database is a handle to the database that includes Collection. % True if Database is a handle to the database that includes Collection.


collection_database(Collection, Database) :- collection_database(Collection, Database) :-
util:get_arg(Collection, 1, Database). mongo_util:get_arg(Collection, 1, Database).


%% collection_name(+Collection, -CollectionName) is det. %% collection_name(+Collection, -CollectionName) is det.
% %
Expand All @@ -50,7 +50,7 @@
% True if Namespace is the namespace name for Collection. % True if Namespace is the namespace name for Collection.


collection_namespace(Collection, Namespace) :- collection_namespace(Collection, Namespace) :-
util:get_arg(Collection, 2, Namespace). mongo_util:get_arg(Collection, 2, Namespace).


%% collection_connection(+Collection, -Connection) is det. %% collection_connection(+Collection, -Connection) is det.
% %
Expand Down
6 changes: 3 additions & 3 deletions src/mongo_command.pl
Expand Up @@ -13,7 +13,7 @@
get_last_error/2 get_last_error/2
]). ]).


:- include(misc(common)). :- include(include/common).


command_collection('$cmd'). command_collection('$cmd').
namespace_collection('system.namespaces'). namespace_collection('system.namespaces').
Expand Down Expand Up @@ -123,9 +123,9 @@
repack_collection_names(Pairs, Names). repack_collection_names(Pairs, Names).


acceptable_collection([name-Namespace]) :- acceptable_collection([name-Namespace]) :-
\+ util:atom_contains(Namespace, '$'). \+ mongo_util:atom_contains(Namespace, '$').
acceptable_collection([name-Namespace]) :- acceptable_collection([name-Namespace]) :-
util:atom_contains(Namespace, '.oplog.$'). mongo_util:atom_contains(Namespace, '.oplog.$').


repack_collection([name-Namespace], Name) :- repack_collection([name-Namespace], Name) :-
mongo_collection:collection_without_namespace(Namespace, Name). mongo_collection:collection_without_namespace(Namespace, Name).
Expand Down
2 changes: 1 addition & 1 deletion src/mongo_command.plt
@@ -1,4 +1,4 @@
:- include(misc(common)). :- include(include/common).


:- begin_tests('mongo commands'). :- begin_tests('mongo commands').


Expand Down
4 changes: 2 additions & 2 deletions src/mongo_connection.pl
Expand Up @@ -11,7 +11,7 @@
read_reply/4 read_reply/4
]). ]).


:- include(misc(common)). :- include(include/common).


%% new_connection(-Connection) is det. %% new_connection(-Connection) is det.
%% new_connection(+Host, +Port, -Connection) is det. %% new_connection(+Host, +Port, -Connection) is det.
Expand All @@ -30,7 +30,7 @@
Connection = connection(Socket). Connection = connection(Socket).


connection_socket(Connection, Socket) :- connection_socket(Connection, Socket) :-
util:get_arg(Connection, 1, Socket). mongo_util:get_arg(Connection, 1, Socket).


%% free_connection(+Connection) is det. %% free_connection(+Connection) is det.
% %
Expand Down
6 changes: 3 additions & 3 deletions src/mongo_cursor.pl
Expand Up @@ -10,16 +10,16 @@
cursor_exhaust/2 cursor_exhaust/2
]). ]).


:- include(misc(common)). :- include(include/common).


new_cursor(Collection, CursorId, Cursor) :- new_cursor(Collection, CursorId, Cursor) :-
Cursor = cursor(Collection, CursorId). Cursor = cursor(Collection, CursorId).


cursor_collection(Cursor, Collection) :- cursor_collection(Cursor, Collection) :-
util:get_arg(Cursor, 1, Collection). mongo_util:get_arg(Cursor, 1, Collection).


cursor_id(Cursor, CursorId) :- cursor_id(Cursor, CursorId) :-
util:get_arg(Cursor, 2, CursorId). mongo_util:get_arg(Cursor, 2, CursorId).


%% cursor_kill(+Cursor) is det. %% cursor_kill(+Cursor) is det.
% %
Expand Down
2 changes: 1 addition & 1 deletion src/mongo_cursor.plt
@@ -1,4 +1,4 @@
:- include(misc(common)). :- include(include/common).


:- begin_tests('mongo:cursor_kill/1'). :- begin_tests('mongo:cursor_kill/1').


Expand Down
6 changes: 3 additions & 3 deletions src/mongo_database.pl
Expand Up @@ -9,7 +9,7 @@
get_collection/3 get_collection/3
]). ]).


:- include(misc(common)). :- include(include/common).


%% new_database(+Connection, +DatabaseName, -Database) is det. %% new_database(+Connection, +DatabaseName, -Database) is det.
% %
Expand All @@ -25,14 +25,14 @@
% True if Connection is the connection used to access Database. % True if Connection is the connection used to access Database.


database_connection(Database, Connection) :- database_connection(Database, Connection) :-
util:get_arg(Database, 1, Connection). mongo_util:get_arg(Database, 1, Connection).


%% database_name(+Database, -DatabaseName) is det. %% database_name(+Database, -DatabaseName) is det.
% %
% True if DatabaseName is the name of Database. % True if DatabaseName is the name of Database.


database_name(Database, DatabaseName) :- database_name(Database, DatabaseName) :-
util:get_arg(Database, 2, DatabaseName). mongo_util:get_arg(Database, 2, DatabaseName).


%% get_collection(+Database, +CollectionName, -Collection) is det. %% get_collection(+Database, +CollectionName, -Collection) is det.
% %
Expand Down
2 changes: 1 addition & 1 deletion src/mongo_defaults.pl
Expand Up @@ -7,7 +7,7 @@
port/1 port/1
]). ]).


:- include(misc(common)). :- include(include/common).


%% host(?Host) is semidet. %% host(?Host) is semidet.
% %
Expand Down
2 changes: 1 addition & 1 deletion src/mongo_delete.pl
Expand Up @@ -7,7 +7,7 @@
delete/3 delete/3
]). ]).


:- include(misc(common)). :- include(include/common).


%% delete(+Collection, +Selector) is det. %% delete(+Collection, +Selector) is det.
% %
Expand Down
2 changes: 1 addition & 1 deletion src/mongo_delete.plt
@@ -1,4 +1,4 @@
:- include(misc(common)). :- include(include/common).


:- begin_tests('mongo:delete/2'). :- begin_tests('mongo:delete/2').


Expand Down
2 changes: 1 addition & 1 deletion src/mongo_find.pl
Expand Up @@ -10,7 +10,7 @@
find/8 find/8
]). ]).


:- include(misc(common)). :- include(include/common).


%% find_one(+Collection, +Query, -Doc) is det. %% find_one(+Collection, +Query, -Doc) is det.
% %
Expand Down
2 changes: 1 addition & 1 deletion src/mongo_find.plt
@@ -1,4 +1,4 @@
:- include(misc(common)). :- include(include/common).


:- begin_tests('mongo:find/7'). :- begin_tests('mongo:find/7').


Expand Down
2 changes: 1 addition & 1 deletion src/mongo_insert.pl
Expand Up @@ -7,7 +7,7 @@
insert_batch/3 insert_batch/3
]). ]).


:- include(misc(common)). :- include(include/common).


%% insert(+Collection, +Doc) is det. %% insert(+Collection, +Doc) is det.
% %
Expand Down
6 changes: 3 additions & 3 deletions src/mongo_insert.plt
@@ -1,12 +1,12 @@
:- include(misc(common)). :- include(include/common).


:- begin_tests('mongo:insert/2'). :- begin_tests('mongo:insert/2').


test('insert', [ test('insert', [
setup(mongo_test_helper:up(Conn,Coll)), setup(mongo_test_helper:up(Conn,Coll)),
cleanup(mongo_test_helper:down(Conn)) cleanup(mongo_test_helper:down(Conn))
]) :- ]) :-
util:ms_since_epoch(MilliSeconds), mongo_util:ms_since_epoch(MilliSeconds),
Doc = Doc =
[ [
hello - [åäö,5.05], hello - [åäö,5.05],
Expand All @@ -23,7 +23,7 @@ test('insert', [
setup(mongo_test_helper:up(Conn,Coll)), setup(mongo_test_helper:up(Conn,Coll)),
cleanup(mongo_test_helper:down(Conn)) cleanup(mongo_test_helper:down(Conn))
]) :- ]) :-
util:ms_since_epoch(MilliSeconds), mongo_util:ms_since_epoch(MilliSeconds),
Doc = Doc =
[ [
hello - world, hello - world,
Expand Down
6 changes: 3 additions & 3 deletions src/mongo_socket.pl
Expand Up @@ -9,7 +9,7 @@
receive_n_bytes/3 receive_n_bytes/3
]). ]).


:- include(misc(common)). :- include(include/common).


%% new_socket(+Host, +Port, -Socket) is det. %% new_socket(+Host, +Port, -Socket) is det.
% %
Expand All @@ -30,10 +30,10 @@
throw(mongo_error('could not connect to server', [Exception])). throw(mongo_error('could not connect to server', [Exception])).


socket_read(Socket, ReadStream) :- socket_read(Socket, ReadStream) :-
util:get_arg(Socket, 1, ReadStream). mongo_util:get_arg(Socket, 1, ReadStream).


socket_write(Socket, WriteStream) :- socket_write(Socket, WriteStream) :-
util:get_arg(Socket, 2, WriteStream). mongo_util:get_arg(Socket, 2, WriteStream).


%% free_socket(+Socket) is det. %% free_socket(+Socket) is det.
% %
Expand Down
4 changes: 2 additions & 2 deletions src/mongo_test_helper.pl
Expand Up @@ -13,7 +13,7 @@
create_n_docs/2 create_n_docs/2
]). ]).


:- include(misc(common)). :- include(include/common).


:- dynamic asserted_database_name/1. :- dynamic asserted_database_name/1.


Expand All @@ -27,7 +27,7 @@
asserted_database_name(DbName), asserted_database_name(DbName),
!. !.
database_name(DbName) :- database_name(DbName) :-
util:ms_since_epoch(Millis), mongo_util:ms_since_epoch(Millis),
core:atomic_list_concat([prolongo_test_suite,Millis], '-', DbName), core:atomic_list_concat([prolongo_test_suite,Millis], '-', DbName),
assert(asserted_database_name(DbName)). assert(asserted_database_name(DbName)).


Expand Down
2 changes: 1 addition & 1 deletion src/mongo_update.pl
Expand Up @@ -9,7 +9,7 @@
update_all/3 update_all/3
]). ]).


:- include(misc(common)). :- include(include/common).


%% upsert(+Collection, +Selector, +Modifier) is det. %% upsert(+Collection, +Selector, +Modifier) is det.
% %
Expand Down
2 changes: 1 addition & 1 deletion src/mongo_update.plt
@@ -1,4 +1,4 @@
:- include(misc(common)). :- include(include/common).


:- begin_tests('mongo:upsert/3'). :- begin_tests('mongo:upsert/3').


Expand Down

0 comments on commit f585502

Please sign in to comment.