Merge lp:~thisfred/u1db/fix-local-gen-before-sync into lp:u1db

Proposed by Eric Casteleijn
Status: Merged
Approved by: Eric Casteleijn
Approved revision: 384
Merged at revision: 381
Proposed branch: lp:~thisfred/u1db/fix-local-gen-before-sync
Merge into: lp:u1db
Diff against target: 123 lines (+28/-12)
6 files modified
include/u1db/u1db.h (+6/-2)
include/u1db/u1db_internal.h (+5/-0)
src/u1db.c (+2/-6)
u1db/tests/c_backend_wrapper.pyx (+4/-2)
u1db/tests/test_c_backend.py (+6/-1)
u1db/tests/test_sync.py (+5/-1)
To merge this branch: bzr merge lp:~thisfred/u1db/fix-local-gen-before-sync
Reviewer Review Type Date Requested Status
John A Meinel (community) Approve
Review via email: mp+119705@code.launchpad.net

Commit message

Fixed local_gen to be an OUT parameter only, and return it from sync()

Description of the change

Fixed local_gen to be an OUT parameter only, and return it from sync()

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 8/15/2012 2:42 PM, Eric Casteleijn wrote:
> Eric Casteleijn has proposed merging
> lp:~thisfred/u1db/fix-local-gen-before-sync into lp:u1db.
>
> Requested reviews: Ubuntu One hackers (ubuntuone-hackers)
>
> For more details, see:
> https://code.launchpad.net/~thisfred/u1db/fix-local-gen-before-sync/+merge/119705
>
> Fixed local_gen to be an OUT parameter only, and return it from
> sync()
>

     // fprintf(stderr, "Starting\n");
- - if (db == NULL || target == NULL || local_gen_before_sync == NULL) {
+ if (db == NULL || target == NULL) {
         // fprintf(stderr, "DB, target, or local are NULL\n");

You should probably still check that "local_gen == NULL" here, so that
we generate an INVALID_PARAMETER error if it is not supplied. Or are
you intentionally making it optional? If so, you should update the
docstring to indicate that.

The rest looks good.

 merge: approve

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlArrJsACgkQJdeBCYSNAAPoygCgnAVKFl2EoKukAwlohz/DRhsd
5bsAn3vlT/AqJR4S5yfIIlgC9tQDedtt
=dSwQ
-----END PGP SIGNATURE-----

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (7.3 KiB)

The attempt to merge lp:~thisfred/u1db/fix-local-gen-before-sync into lp:u1db failed. Below is the output from the failed tests.

-- The C compiler identification is GNU 4.7.1
-- The CXX compiler identification is GNU 4.7.1
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found Cython: /usr/bin/cython
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.26.0")
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")
-- checking for module 'oauth'
-- found oauth, version 0.9.7
-- Found OAuth: /usr/lib/x86_64-linux-gnu/liboauth.so
-- checking for module 'json'
-- found json, version 0.9
-- Found JSON: /usr/lib/x86_64-linux-gnu/libjson.so
-- checking for module 'sqlite3'
-- found sqlite3, version 3.7.13
-- Found Sqlite3: /usr/lib/x86_64-linux-gnu/libsqlite3.so
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/tarmac/cache/u1db/trunk
[ 11%] Generating u1db_schema.c
Scanning dependencies of target u1db
[ 22%] Building C object src/CMakeFiles/u1db.dir/mkstemp_compat.c.o
[ 33%] Building C object src/CMakeFiles/u1db.dir/u1db.c.o
[ 44%] Building C object src/CMakeFiles/u1db.dir/u1db_http_sync_target.c.o
[ 55%] Building C object src/CMakeFiles/u1db.dir/u1db_query.c.o
[ 66%] Building C object src/CMakeFiles/u1db.dir/u1db_sync_target.c.o
[ 77%] Building C object src/CMakeFiles/u1db.dir/u1db_uuid.c.o
[ 88%] Building C object src/CMakeFiles/u1db.dir/u1db_vectorclock.c.o
[100%] Building C object src/CMakeFiles/u1db.dir/u1db_schema.c.o
Linking C static library libu1db.a
[100%] Built target u1db
Scanning dependencies of target ReplicatePythonSourceTree
[100%] Built target ReplicatePythonSourceTree
Scanning dependencies of target build-debug
running build_ext
cythoning u1db/tests/c_backend_wrapper.pyx to u1db/tests/c_backend_wrapper.c
building 'u1db.tests.c_backend_wrapper' extension
creating build
creating build/temp.linux-x86_64-2.7-pydebug
creating build/temp.linux-x86_64-2.7-pydebug/u1db
creating build/temp.linux-x86_64-2.7-pydebug/u1db/tests
gcc -pthread -fno-strict-aliasing -g -O0 -Wall -Wstrict-prototypes -fPIC -Iinclude -I/mnt/tarmac/cache/u1db/trunk/include -I/usr/include/python2.7_d -c u1db/tests/c_backend_wrapper.c -o build/temp.linux-x86_64-2.7-pydebug/u1db/tests/c_backend_wrapper.o
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-2.7-pydebug/u1db/tests/c_backend_wrapper.o -Lsrc -lu1db -lsqlite3 -loauth -lcurl -ljson -o /mnt/tarmac/cache/u1db/trunk/u1db/tests/c_backend_wrapper_d.so
[100%] Built target build-debug
Scanning dependencies of target check-valgrind
Tests running...
======================================================================
FAIL: u1db.tests.test_sync.DatabaseSyncTests.test_sync_tracks_db_generation_of_other(c,csync)
----------------------------------------------------------------------
Tr...

Read more...

Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (7.3 KiB)

The attempt to merge lp:~thisfred/u1db/fix-local-gen-before-sync into lp:u1db failed. Below is the output from the failed tests.

-- The C compiler identification is GNU 4.7.1
-- The CXX compiler identification is GNU 4.7.1
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found Cython: /usr/bin/cython
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.26.0")
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")
-- checking for module 'oauth'
-- found oauth, version 0.9.7
-- Found OAuth: /usr/lib/x86_64-linux-gnu/liboauth.so
-- checking for module 'json'
-- found json, version 0.9
-- Found JSON: /usr/lib/x86_64-linux-gnu/libjson.so
-- checking for module 'sqlite3'
-- found sqlite3, version 3.7.13
-- Found Sqlite3: /usr/lib/x86_64-linux-gnu/libsqlite3.so
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/tarmac/cache/u1db/trunk
Scanning dependencies of target ReplicatePythonSourceTree
[ 0%] Built target ReplicatePythonSourceTree
[ 11%] Generating u1db_schema.c
Scanning dependencies of target u1db
[ 22%] Building C object src/CMakeFiles/u1db.dir/mkstemp_compat.c.o
[ 33%] Building C object src/CMakeFiles/u1db.dir/u1db.c.o
[ 44%] Building C object src/CMakeFiles/u1db.dir/u1db_http_sync_target.c.o
[ 55%] Building C object src/CMakeFiles/u1db.dir/u1db_query.c.o
[ 66%] Building C object src/CMakeFiles/u1db.dir/u1db_sync_target.c.o
[ 77%] Building C object src/CMakeFiles/u1db.dir/u1db_uuid.c.o
[ 88%] Building C object src/CMakeFiles/u1db.dir/u1db_vectorclock.c.o
[100%] Building C object src/CMakeFiles/u1db.dir/u1db_schema.c.o
Linking C static library libu1db.a
[100%] Built target u1db
Scanning dependencies of target build-debug
running build_ext
cythoning u1db/tests/c_backend_wrapper.pyx to u1db/tests/c_backend_wrapper.c
building 'u1db.tests.c_backend_wrapper' extension
creating build
creating build/temp.linux-x86_64-2.7-pydebug
creating build/temp.linux-x86_64-2.7-pydebug/u1db
creating build/temp.linux-x86_64-2.7-pydebug/u1db/tests
gcc -pthread -fno-strict-aliasing -g -O0 -Wall -Wstrict-prototypes -fPIC -Iinclude -I/mnt/tarmac/cache/u1db/trunk/include -I/usr/include/python2.7_d -c u1db/tests/c_backend_wrapper.c -o build/temp.linux-x86_64-2.7-pydebug/u1db/tests/c_backend_wrapper.o
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-2.7-pydebug/u1db/tests/c_backend_wrapper.o -Lsrc -lu1db -lsqlite3 -loauth -lcurl -ljson -o /mnt/tarmac/cache/u1db/trunk/u1db/tests/c_backend_wrapper_d.so
[100%] Built target build-debug
Scanning dependencies of target check-valgrind
Tests running...
======================================================================
FAIL: u1db.tests.test_sync.DatabaseSyncTests.test_sync_tracks_db_generation_of_other(c,csync)
----------------------------------------------------------------------
Tr...

Read more...

384. By Eric Casteleijn

init another int

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/u1db/u1db.h'
2--- include/u1db/u1db.h 2012-08-14 21:22:44 +0000
3+++ include/u1db/u1db.h 2012-08-15 15:38:20 +0000
4@@ -272,9 +272,13 @@
5 /**
6 * Synchronize db with the database at url.
7 *
8- * @param url The URL of a remote database to synchronize with.
9+ * @param url The URL of a remote database to synchronize with.
10+ * @param local_gen (OUT) The local generation at the start of the sync. This
11+ * is useful for applications to call whats_changed
12+ * with to find out which documents were affected by a
13+ * sync.
14 */
15-int u1db_sync(u1database *db, const char *url);
16+int u1db_sync(u1database *db, const char *url, int *local_gen);
17
18 /**
19 * Create an index that you can query for matching documents.
20
21=== modified file 'include/u1db/u1db_internal.h'
22--- include/u1db/u1db_internal.h 2012-07-26 18:07:54 +0000
23+++ include/u1db/u1db_internal.h 2012-08-15 15:38:20 +0000
24@@ -540,6 +540,11 @@
25
26 /**
27 * Sync a database with a sync target.
28+ *
29+ * @param local_gen_before_sync (OUT) Will return the local generation before
30+ * before the sync started, which clients
31+ * can use to know what was changed during
32+ * the sync.
33 */
34 int u1db__sync_db_to_target(u1database *db, u1db_sync_target *target,
35 int *local_gen_before_sync);
36
37=== modified file 'src/u1db.c'
38--- src/u1db.c 2012-08-14 23:05:22 +0000
39+++ src/u1db.c 2012-08-15 15:38:20 +0000
40@@ -2077,19 +2077,15 @@
41 }
42
43 int
44-u1db_sync(u1database *db, const char *url)
45+u1db_sync(u1database *db, const char *url, int *local_gen)
46 {
47 int status = U1DB_OK;
48- int local_gen;
49 u1db_sync_target *target = NULL;
50 status = u1db__create_http_sync_target(url, &target);
51 if (status != U1DB_OK) {
52 goto finish;
53 }
54- status = u1db__get_generation(db, &local_gen);
55- if (status != U1DB_OK)
56- return status;
57- status = u1db__sync_db_to_target(db, target, &local_gen);
58+ status = u1db__sync_db_to_target(db, target, local_gen);
59 finish:
60 if (target != NULL) {
61 u1db__free_sync_target(&target);
62
63=== modified file 'u1db/tests/c_backend_wrapper.pyx'
64--- u1db/tests/c_backend_wrapper.pyx 2012-08-14 23:05:22 +0000
65+++ u1db/tests/c_backend_wrapper.pyx 2012-08-15 15:38:20 +0000
66@@ -98,7 +98,7 @@
67 u1db_trans_info_callback cb)
68 int u1db_get_doc_conflicts(u1database *db, char *doc_id, void *context,
69 u1db_doc_callback cb)
70- int u1db_sync(u1database *db, const_char_ptr url) nogil
71+ int u1db_sync(u1database *db, const_char_ptr url, int *local_gen) nogil
72 int u1db_create_index_list(u1database *db, char *index_name,
73 int n_expressions, const_char_ptr *expressions)
74 int u1db_create_index(u1database *db, char *index_name, int n_expressions,
75@@ -1232,10 +1232,12 @@
76
77 def sync(self, url):
78 cdef const_char_ptr c_url
79+ cdef int local_gen = 0
80 c_url = url
81 with nogil:
82- status = u1db_sync(self._db, c_url)
83+ status = u1db_sync(self._db, c_url, &local_gen)
84 handle_status("sync", status)
85+ return local_gen
86
87 def list_indexes(self):
88 a_list = []
89
90=== modified file 'u1db/tests/test_c_backend.py'
91--- u1db/tests/test_c_backend.py 2012-08-14 21:03:06 +0000
92+++ u1db/tests/test_c_backend.py 2012-08-15 15:38:20 +0000
93@@ -484,7 +484,12 @@
94 url = self.getURL('test.db')
95 db = c_backend_wrapper.CDatabase(':memory:')
96 doc = db.create_doc_from_json(tests.simple_doc)
97- db.sync(url)
98+ local_gen_before_sync = db.sync(url)
99+ gen, _, changes = db.whats_changed(local_gen_before_sync)
100+ self.assertEqual(1, len(changes))
101+ self.assertEqual(mem_doc.doc_id, changes[0][0])
102+ self.assertEqual(1, gen - local_gen_before_sync)
103+ self.assertEqual(1, local_gen_before_sync)
104 self.assertGetDoc(mem_db, doc.doc_id, doc.rev, doc.get_json(), False)
105 self.assertGetDoc(db, mem_doc.doc_id, mem_doc.rev, mem_doc.get_json(),
106 False)
107
108=== modified file 'u1db/tests/test_sync.py'
109--- u1db/tests/test_sync.py 2012-08-09 20:46:13 +0000
110+++ u1db/tests/test_sync.py 2012-08-15 15:38:20 +0000
111@@ -1053,7 +1053,11 @@
112 doc1 = self.db.create_doc_from_json(tests.simple_doc)
113 doc2 = self.db2.create_doc_from_json(tests.nested_doc)
114 db2_url = self.getURL('test2.db')
115- self.db.sync(db2_url)
116+ local_gen_before_sync = self.db.sync(db2_url)
117+ gen, _, changes = self.db.whats_changed(local_gen_before_sync)
118+ self.assertEqual(1, len(changes))
119+ self.assertEqual(doc2.doc_id, changes[0][0])
120+ self.assertEqual(1, gen - local_gen_before_sync)
121 self.assertGetDoc(self.db2, doc1.doc_id, doc1.rev, tests.simple_doc,
122 False)
123 self.assertGetDoc(self.db, doc2.doc_id, doc2.rev, tests.nested_doc,

Subscribers

People subscribed via source and target branches