Merge lp:~thisfred/u1db/unconfuse_sync_info into lp:u1db

Proposed by Eric Casteleijn on 2012-07-03
Status: Merged
Approved by: Eric Casteleijn on 2012-07-03
Approved revision: 339
Merged at revision: 338
Proposed branch: lp:~thisfred/u1db/unconfuse_sync_info
Merge into: lp:u1db
Diff against target: 774 lines (+147/-116)
15 files modified
include/u1db/u1db_internal.h (+4/-4)
src/u1db.c (+6/-6)
src/u1db_sync_target.c (+5/-4)
u1db/__init__.py (+11/-8)
u1db/backends/__init__.py (+5/-3)
u1db/backends/inmemory.py (+13/-10)
u1db/backends/sqlite_backend.py (+13/-10)
u1db/sync.py (+2/-2)
u1db/tests/c_backend_wrapper.pyx (+12/-11)
u1db/tests/test_backends.py (+29/-23)
u1db/tests/test_c_backend.py (+2/-2)
u1db/tests/test_http_app.py (+10/-6)
u1db/tests/test_https.py (+2/-1)
u1db/tests/test_remote_sync_target.py (+7/-4)
u1db/tests/test_sync.py (+26/-22)
To merge this branch: bzr merge lp:~thisfred/u1db/unconfuse_sync_info
Reviewer Review Type Date Requested Status
Samuele Pedroni 2012-07-03 Approve on 2012-07-03
Review via email: mp+113214@code.launchpad.net

Commit Message

renamed _get_sync_gen_info and _set_sync_info to _get_replica_gen_and_trans_id and _set_replica_gen_and_trans_id respectively, to not confuse them with the get_sync_info method.

Description of the Change

renamed _get_sync_gen_info and _set_sync_info to _get_replica_gen_and_trans_id and _set_replica_gen_and_trans_id respectively, to not confuse them with the get_sync_info method.

To post a comment you must log in.
Samuele Pedroni (pedronis) wrote :

141 - generation the other replica was at. See also _get_sync_gen_info.
142 + generation the other replica was at. See also
143 + _replica_gen_and_trans_id.

that should be _get_replica_gen_and_trans_id

review: Approve
339. By Eric Casteleijn on 2012-07-03

typo in docstring

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/u1db/u1db_internal.h'
2--- include/u1db/u1db_internal.h 2012-06-22 00:03:55 +0000
3+++ include/u1db/u1db_internal.h 2012-07-03 14:37:18 +0000
4@@ -300,15 +300,15 @@
5 * @param trans_id (OUT) The transaction id associated with the generation.
6 * Callers must free the data.
7 */
8-int u1db__get_sync_gen_info(u1database *db, const char *replica_uid,
9- int *generation, char **trans_id);
10+int u1db__get_replica_gen_and_trans_id(u1database *db, const char *replica_uid,
11+ int *generation, char **trans_id);
12
13 /**
14 * Set the known sync generation for another replica.
15 *
16 */
17-int u1db__set_sync_info(u1database *db, const char *replica_uid,
18- int generation, const char *trans_id);
19+int u1db__set_replica_gen_and_trans_id(u1database *db, const char *replica_uid,
20+ int generation, const char *trans_id);
21
22 /**
23 * Internal sync api, get the stored information about another machine.
24
25=== modified file 'src/u1db.c'
26--- src/u1db.c 2012-06-22 00:03:55 +0000
27+++ src/u1db.c 2012-07-03 14:37:18 +0000
28@@ -764,7 +764,7 @@
29 int status = U1DB_OK;
30
31 *state = U1DB_OK;
32- status = u1db__get_sync_gen_info(
33+ status = u1db__get_replica_gen_and_trans_id(
34 db, replica_uid, &old_generation, &old_trans_id);
35 if (status != U1DB_OK)
36 goto finish;
37@@ -908,7 +908,7 @@
38 (stored_doc_rev != NULL));
39 }
40 if (status == U1DB_OK && replica_uid != NULL) {
41- status = u1db__set_sync_info(
42+ status = u1db__set_replica_gen_and_trans_id(
43 db, replica_uid, replica_gen, replica_trans_id);
44 }
45 if (status == U1DB_OK && at_gen != NULL) {
46@@ -1613,8 +1613,8 @@
47
48
49 int
50-u1db__get_sync_gen_info(u1database *db, const char *replica_uid,
51- int *generation, char **trans_id)
52+u1db__get_replica_gen_and_trans_id(u1database *db, const char *replica_uid,
53+ int *generation, char **trans_id)
54 {
55 int status;
56 sqlite3_stmt *statement;
57@@ -1664,8 +1664,8 @@
58
59
60 int
61-u1db__set_sync_info(u1database *db, const char *replica_uid,
62- int generation, const char *trans_id)
63+u1db__set_replica_gen_and_trans_id(u1database *db, const char *replica_uid,
64+ int generation, const char *trans_id)
65 {
66 int status;
67 sqlite3_stmt *statement;
68
69=== modified file 'src/u1db_sync_target.c'
70--- src/u1db_sync_target.c 2012-06-18 18:21:38 +0000
71+++ src/u1db_sync_target.c 2012-07-03 14:37:18 +0000
72@@ -125,7 +125,7 @@
73 db = (u1database *)st->implementation;
74 status = u1db_get_replica_uid(db, st_replica_uid);
75 if (status != U1DB_OK) { goto finish; }
76- status = u1db__get_sync_gen_info(
77+ status = u1db__get_replica_gen_and_trans_id(
78 db, source_replica_uid, source_gen, source_trans_id);
79 if (status != U1DB_OK) { goto finish; }
80 status = u1db__get_generation(db, st_gen);
81@@ -148,7 +148,8 @@
82 if (status != U1DB_OK) { goto finish; }
83 }
84 db = (u1database *)st->implementation;
85- status = u1db__set_sync_info(db, source_replica_uid, source_gen, trans_id);
86+ status = u1db__set_replica_gen_and_trans_id(
87+ db, source_replica_uid, source_gen, trans_id);
88 finish:
89 return status;
90 }
91@@ -617,7 +618,7 @@
92 status = u1db_validate_gen_and_trans_id(
93 db, local_gen_known_by_target, local_trans_id_known_by_target);
94 if (status != U1DB_OK) { goto finish; }
95- status = u1db__get_sync_gen_info(db, target_uid,
96+ status = u1db__get_replica_gen_and_trans_id(db, target_uid,
97 &target_gen_known_by_local, &target_trans_id_known_by_local);
98 if (status != U1DB_OK) { goto finish; }
99 local_target_trans_id = target_trans_id_known_by_local;
100@@ -655,7 +656,7 @@
101 if (status != U1DB_OK) { goto finish; }
102 // Now we successfully sent and received docs, make sure we record the
103 // current remote generation
104- status = u1db__set_sync_info(
105+ status = u1db__set_replica_gen_and_trans_id(
106 db, target_uid, target_gen_known_by_local,
107 target_trans_id_known_by_local);
108 if (status != U1DB_OK) { goto finish; }
109
110=== modified file 'u1db/__init__.py'
111--- u1db/__init__.py 2012-06-27 18:56:17 +0000
112+++ u1db/__init__.py 2012-07-03 14:37:18 +0000
113@@ -275,8 +275,9 @@
114 from u1db.remote.http_target import HTTPSyncTarget
115 return Synchronizer(self, HTTPSyncTarget(url)).sync()
116
117- def _get_sync_gen_info(self, other_replica_uid):
118- """Return the last known information about the other db replica.
119+ def _get_replica_gen_and_trans_id(self, other_replica_uid):
120+ """Return the last known generation and transaction id for the other db
121+ replica.
122
123 When you do a synchronization with another replica, the Database keeps
124 track of what generation the other database replica was at, and what
125@@ -289,21 +290,23 @@
126 encountered during synchronization. If we've never synchronized
127 with the replica, this is (0, '').
128 """
129- raise NotImplementedError(self._get_sync_gen_info)
130+ raise NotImplementedError(self._replica_gen_and_trans_id)
131
132- def _set_sync_info(self, other_replica_uid, other_generation,
133- other_transaction_id):
134- """Set the last-known generation for the other database replica.
135+ def _set_replica_gen_and_trans_id(self, other_replica_uid,
136+ other_generation, other_transaction_id):
137+ """Set the last-known generation and transaction id for the other
138+ database replica.
139
140 We have just performed some synchronization, and we want to track what
141- generation the other replica was at. See also _get_sync_gen_info.
142+ generation the other replica was at. See also
143+ _get_replica_gen_and_trans_id.
144 :param other_replica_uid: The U1DB identifier for the other replica.
145 :param other_generation: The generation number for the other replica.
146 :param other_transaction_id: The transaction id associated with the
147 generation.
148 :return: None
149 """
150- raise NotImplementedError(self._set_sync_info)
151+ raise NotImplementedError(self._set_replica_gen_and_trans_id)
152
153 def _put_doc_if_newer(self, doc, save_conflict, replica_uid=None,
154 replica_gen=None, replica_trans_id=None):
155
156=== modified file 'u1db/backends/__init__.py'
157--- u1db/backends/__init__.py 2012-06-19 19:36:50 +0000
158+++ u1db/backends/__init__.py 2012-07-03 14:37:18 +0000
159@@ -119,8 +119,9 @@
160 replica, *or* it must be the same and the transaction_id must be the
161 same as well.
162 """
163- old_generation, old_transaction_id = self._get_sync_gen_info(
164- other_replica_uid)
165+ (old_generation,
166+ old_transaction_id) = self._get_replica_gen_and_trans_id(
167+ other_replica_uid)
168 if other_generation < old_generation:
169 if cur_vcr.is_newer(other_vcr):
170 return 'superseded'
171@@ -174,7 +175,8 @@
172 if save_conflict:
173 self._force_doc_sync_conflict(doc)
174 if replica_uid is not None and replica_gen is not None:
175- self._do_set_sync_info(replica_uid, replica_gen, replica_trans_id)
176+ self._do_set_replica_gen_and_trans_id(
177+ replica_uid, replica_gen, replica_trans_id)
178 return state, self._get_generation()
179
180 def _ensure_maximal_rev(self, cur_rev, extra_revs):
181
182=== modified file 'u1db/backends/inmemory.py'
183--- u1db/backends/inmemory.py 2012-06-19 19:36:50 +0000
184+++ u1db/backends/inmemory.py 2012-07-03 14:37:18 +0000
185@@ -54,16 +54,17 @@
186 # may be closing it, while another wants to inspect the results.
187 pass
188
189- def _get_sync_gen_info(self, other_replica_uid):
190+ def _get_replica_gen_and_trans_id(self, other_replica_uid):
191 return self._other_generations.get(other_replica_uid, (0, ''))
192
193- def _set_sync_info(self, other_replica_uid, other_generation,
194- other_transaction_id):
195- self._do_set_sync_info(other_replica_uid, other_generation,
196- other_transaction_id)
197+ def _set_replica_gen_and_trans_id(self, other_replica_uid,
198+ other_generation, other_transaction_id):
199+ self._do_set_replica_gen_and_trans_id(
200+ other_replica_uid, other_generation, other_transaction_id)
201
202- def _do_set_sync_info(self, other_replica_uid, other_generation,
203- other_transaction_id):
204+ def _do_set_replica_gen_and_trans_id(self, other_replica_uid,
205+ other_generation,
206+ other_transaction_id):
207 # TODO: to handle race conditions, we may want to check if the current
208 # value is greater than this new value.
209 self._other_generations[other_replica_uid] = (other_generation,
210@@ -443,7 +444,8 @@
211 class InMemorySyncTarget(CommonSyncTarget):
212
213 def get_sync_info(self, source_replica_uid):
214- source_gen, trans_id = self._db._get_sync_gen_info(source_replica_uid)
215+ source_gen, trans_id = self._db._get_replica_gen_and_trans_id(
216+ source_replica_uid)
217 return (self._db._replica_uid, len(self._db._transaction_log),
218 source_gen, trans_id)
219
220@@ -451,5 +453,6 @@
221 source_transaction_id):
222 if self._trace_hook:
223 self._trace_hook('record_sync_info')
224- self._db._set_sync_info(source_replica_uid, source_replica_generation,
225- source_transaction_id)
226+ self._db._set_replica_gen_and_trans_id(
227+ source_replica_uid, source_replica_generation,
228+ source_transaction_id)
229
230=== modified file 'u1db/backends/sqlite_backend.py'
231--- u1db/backends/sqlite_backend.py 2012-06-19 19:36:50 +0000
232+++ u1db/backends/sqlite_backend.py 2012-07-03 14:37:18 +0000
233@@ -460,7 +460,7 @@
234 this_doc.has_conflicts = True
235 return [this_doc] + conflict_docs
236
237- def _get_sync_gen_info(self, other_replica_uid):
238+ def _get_replica_gen_and_trans_id(self, other_replica_uid):
239 c = self._db_handle.cursor()
240 c.execute("SELECT known_generation, known_transaction_id FROM sync_log"
241 " WHERE replica_uid = ?",
242@@ -474,14 +474,15 @@
243 trans_id = val[1]
244 return other_gen, trans_id
245
246- def _set_sync_info(self, other_replica_uid, other_generation,
247- other_transaction_id):
248+ def _set_replica_gen_and_trans_id(self, other_replica_uid,
249+ other_generation, other_transaction_id):
250 with self._db_handle:
251- self._do_set_sync_info(other_replica_uid, other_generation,
252- other_transaction_id)
253+ self._do_set_replica_gen_and_trans_id(
254+ other_replica_uid, other_generation, other_transaction_id)
255
256- def _do_set_sync_info(self, other_replica_uid, other_generation,
257- other_transaction_id):
258+ def _do_set_replica_gen_and_trans_id(self, other_replica_uid,
259+ other_generation,
260+ other_transaction_id):
261 c = self._db_handle.cursor()
262 c.execute("INSERT OR REPLACE INTO sync_log VALUES (?, ?, ?)",
263 (other_replica_uid, other_generation,
264@@ -787,7 +788,8 @@
265 class SQLiteSyncTarget(CommonSyncTarget):
266
267 def get_sync_info(self, source_replica_uid):
268- source_gen, trans_id = self._db._get_sync_gen_info(source_replica_uid)
269+ source_gen, trans_id = self._db._get_replica_gen_and_trans_id(
270+ source_replica_uid)
271 my_gen = self._db._get_generation()
272 return self._db._replica_uid, my_gen, source_gen, trans_id
273
274@@ -795,8 +797,9 @@
275 source_replica_transaction_id):
276 if self._trace_hook:
277 self._trace_hook('record_sync_info')
278- self._db._set_sync_info(source_replica_uid, source_replica_generation,
279- source_replica_transaction_id)
280+ self._db._set_replica_gen_and_trans_id(
281+ source_replica_uid, source_replica_generation,
282+ source_replica_transaction_id)
283
284
285 class SQLitePartialExpandDatabase(SQLiteDatabase):
286
287=== modified file 'u1db/sync.py'
288--- u1db/sync.py 2012-06-15 20:56:26 +0000
289+++ u1db/sync.py 2012-07-03 14:37:18 +0000
290@@ -104,7 +104,7 @@
291
292 # this source last-seen database generation for the target
293 (target_last_known_gen,
294- target_trans_id) = self.source._get_sync_gen_info(
295+ target_trans_id) = self.source._get_replica_gen_and_trans_id(
296 self.target_replica_uid)
297 if not changes and target_last_known_gen == target_gen:
298 return my_gen
299@@ -123,7 +123,7 @@
300 self.source._replica_uid, target_last_known_gen,
301 return_doc_cb=self._insert_doc_from_target)
302 # record target synced-up-to generation including applying what we sent
303- self.source._set_sync_info(
304+ self.source._set_replica_gen_and_trans_id(
305 self.target_replica_uid, new_gen, new_trans_id)
306
307 # if gapless record current reached generation with target
308
309=== modified file 'u1db/tests/c_backend_wrapper.pyx'
310--- u1db/tests/c_backend_wrapper.pyx 2012-06-27 18:56:17 +0000
311+++ u1db/tests/c_backend_wrapper.pyx 2012-07-03 14:37:18 +0000
312@@ -220,10 +220,10 @@
313 int has_conflicts, u1db_document **result)
314 int u1db__generate_hex_uuid(char *)
315
316- int u1db__get_sync_gen_info(u1database *db, char *replica_uid,
317- int *generation, char **trans_id)
318- int u1db__set_sync_info(u1database *db, char *replica_uid, int generation,
319- char *trans_id)
320+ int u1db__get_replica_gen_and_trans_id(u1database *db, char *replica_uid,
321+ int *generation, char **trans_id)
322+ int u1db__set_replica_gen_and_trans_id(u1database *db, char *replica_uid,
323+ int generation, char *trans_id)
324 int u1db__sync_get_machine_info(u1database *db, char *other_replica_uid,
325 int *other_db_rev, char **my_replica_uid,
326 int *my_db_rev)
327@@ -1092,22 +1092,23 @@
328 "validate_gen_and_trans_id",
329 u1db_validate_gen_and_trans_id(self._db, generation, trans_id))
330
331- def _get_sync_gen_info(self, replica_uid):
332+ def _get_replica_gen_and_trans_id(self, replica_uid):
333 cdef int generation, status
334 cdef char *trans_id = NULL
335
336- status = u1db__get_sync_gen_info(self._db, replica_uid, &generation,
337- &trans_id)
338- handle_status("_get_sync_gen_info", status)
339+ status = u1db__get_replica_gen_and_trans_id(
340+ self._db, replica_uid, &generation, &trans_id)
341+ handle_status("_get_replica_gen_and_trans_id", status)
342 raw_trans_id = None
343 if trans_id != NULL:
344 raw_trans_id = trans_id
345 free(trans_id)
346 return generation, raw_trans_id
347
348- def _set_sync_info(self, replica_uid, generation, trans_id):
349- handle_status("_set_sync_info",
350- u1db__set_sync_info(self._db, replica_uid, generation, trans_id))
351+ def _set_replica_gen_and_trans_id(self, replica_uid, generation, trans_id):
352+ handle_status("_set_replica_gen_and_trans_id",
353+ u1db__set_replica_gen_and_trans_id(
354+ self._db, replica_uid, generation, trans_id))
355
356 def _sync_exchange(self, docs_info, from_replica_uid, from_machine_rev,
357 last_known_rev):
358
359=== modified file 'u1db/tests/test_backends.py'
360--- u1db/tests/test_backends.py 2012-06-29 16:18:14 +0000
361+++ u1db/tests/test_backends.py 2012-07-03 14:37:18 +0000
362@@ -393,7 +393,7 @@
363 self.assertGetDoc(self.db, doc1.doc_id, doc1.rev, simple_doc, False)
364
365 def test_put_doc_if_newer_newer_generation(self):
366- self.db._set_sync_info('other', 1, 'T-sid')
367+ self.db._set_replica_gen_and_trans_id('other', 1, 'T-sid')
368 doc = self.make_document('doc_id', 'other:2', simple_doc)
369 state, _ = self.db._put_doc_if_newer(
370 doc, save_conflict=False, replica_uid='other', replica_gen=2,
371@@ -401,7 +401,7 @@
372 self.assertEqual('inserted', state)
373
374 def test_put_doc_if_newer_same_generation_same_txid(self):
375- self.db._set_sync_info('other', 1, 'T-sid')
376+ self.db._set_replica_gen_and_trans_id('other', 1, 'T-sid')
377 doc = self.make_document('doc_id', 'other:2', simple_doc)
378 state, _ = self.db._put_doc_if_newer(
379 doc, save_conflict=False, replica_uid='other', replica_gen=1,
380@@ -409,7 +409,7 @@
381 self.assertEqual('superseded', state)
382
383 def test_put_doc_if_newer_wrong_transaction_id(self):
384- self.db._set_sync_info('other', 1, 'T-sid')
385+ self.db._set_replica_gen_and_trans_id('other', 1, 'T-sid')
386 doc = self.make_document('doc_id', 'other:1', simple_doc)
387 self.assertRaises(
388 errors.InvalidTransactionId,
389@@ -422,7 +422,7 @@
390 doc_rev1 = doc.rev
391 doc.set_json(simple_doc)
392 self.db.put_doc(doc)
393- self.db._set_sync_info('other', 5, 'T-sid')
394+ self.db._set_replica_gen_and_trans_id('other', 5, 'T-sid')
395 older_doc = self.make_document(doc.doc_id, doc_rev1, simple_doc)
396 state, _ = self.db._put_doc_if_newer(
397 older_doc, save_conflict=False, replica_uid='other', replica_gen=3,
398@@ -430,7 +430,7 @@
399 self.assertEqual('superseded', state)
400
401 def test_put_doc_if_newer_old_generation_newer_doc(self):
402- self.db._set_sync_info('other', 5, 'T-sid')
403+ self.db._set_replica_gen_and_trans_id('other', 5, 'T-sid')
404 doc = self.make_document('doc_id', 'other:1', simple_doc)
405 self.assertRaises(
406 errors.InvalidGeneration,
407@@ -457,7 +457,7 @@
408 self.db.validate_gen_and_trans_id, gen + 1, trans_id)
409
410 def test_validate_source_gen_and_trans_id_same(self):
411- self.db._set_sync_info('other', 1, 'T-sid')
412+ self.db._set_replica_gen_and_trans_id('other', 1, 'T-sid')
413 v1 = vectorclock.VectorClockRev('other:1|self:1')
414 v2 = vectorclock.VectorClockRev('other:1|self:1')
415 self.assertEqual(
416@@ -465,7 +465,7 @@
417 self.db._validate_source('other', 1, 'T-sid', v1, v2))
418
419 def test_validate_source_gen_newer(self):
420- self.db._set_sync_info('other', 1, 'T-sid')
421+ self.db._set_replica_gen_and_trans_id('other', 1, 'T-sid')
422 v1 = vectorclock.VectorClockRev('other:1|self:1')
423 v2 = vectorclock.VectorClockRev('other:2|self:2')
424 self.assertEqual(
425@@ -473,7 +473,7 @@
426 self.db._validate_source('other', 2, 'T-whatevs', v1, v2))
427
428 def test_validate_source_wrong_txid(self):
429- self.db._set_sync_info('other', 1, 'T-sid')
430+ self.db._set_replica_gen_and_trans_id('other', 1, 'T-sid')
431 v1 = vectorclock.VectorClockRev('other:1|self:1')
432 v2 = vectorclock.VectorClockRev('other:2|self:2')
433 self.assertRaises(
434@@ -481,8 +481,8 @@
435 self.db._validate_source, 'other', 1, 'T-sad', v1, v2)
436
437 def test_validate_source_gen_older_and_vcr_older(self):
438- self.db._set_sync_info('other', 1, 'T-sid')
439- self.db._set_sync_info('other', 2, 'T-sod')
440+ self.db._set_replica_gen_and_trans_id('other', 1, 'T-sid')
441+ self.db._set_replica_gen_and_trans_id('other', 2, 'T-sod')
442 v1 = vectorclock.VectorClockRev('other:1|self:1')
443 v2 = vectorclock.VectorClockRev('other:2|self:2')
444 self.assertEqual(
445@@ -490,8 +490,8 @@
446 self.db._validate_source('other', 1, 'T-sid', v2, v1))
447
448 def test_validate_source_gen_older_vcr_newer(self):
449- self.db._set_sync_info('other', 1, 'T-sid')
450- self.db._set_sync_info('other', 2, 'T-sod')
451+ self.db._set_replica_gen_and_trans_id('other', 1, 'T-sid')
452+ self.db._set_replica_gen_and_trans_id('other', 2, 'T-sod')
453 v1 = vectorclock.VectorClockRev('other:1|self:1')
454 v2 = vectorclock.VectorClockRev('other:2|self:2')
455 self.assertRaises(
456@@ -500,21 +500,23 @@
457
458 def test_put_doc_if_newer_replica_uid(self):
459 doc1 = self.db.create_doc(simple_doc)
460- self.db._set_sync_info('other', 1, 'T-sid')
461+ self.db._set_replica_gen_and_trans_id('other', 1, 'T-sid')
462 doc2 = self.make_document(doc1.doc_id, doc1.rev + '|other:1',
463 nested_doc)
464 self.assertEqual('inserted',
465 self.db._put_doc_if_newer(doc2, save_conflict=False,
466 replica_uid='other', replica_gen=2,
467 replica_trans_id='T-id2')[0])
468- self.assertEqual((2, 'T-id2'), self.db._get_sync_gen_info('other'))
469+ self.assertEqual((2, 'T-id2'), self.db._get_replica_gen_and_trans_id(
470+ 'other'))
471 # Compare to the old rev, should be superseded
472 doc2 = self.make_document(doc1.doc_id, doc1.rev, nested_doc)
473 self.assertEqual('superseded',
474 self.db._put_doc_if_newer(doc2, save_conflict=False,
475 replica_uid='other', replica_gen=3,
476 replica_trans_id='T-id3')[0])
477- self.assertEqual((3, 'T-id3'), self.db._get_sync_gen_info('other'))
478+ self.assertEqual(
479+ (3, 'T-id3'), self.db._get_replica_gen_and_trans_id('other'))
480 # A conflict that isn't saved still records the sync gen, because we
481 # don't need to see it again
482 doc2 = self.make_document(doc1.doc_id, doc1.rev + '|fourth:1',
483@@ -523,13 +525,16 @@
484 self.db._put_doc_if_newer(doc2, save_conflict=False,
485 replica_uid='other', replica_gen=4,
486 replica_trans_id='T-id4')[0])
487- self.assertEqual((4, 'T-id4'), self.db._get_sync_gen_info('other'))
488+ self.assertEqual(
489+ (4, 'T-id4'), self.db._get_replica_gen_and_trans_id('other'))
490
491- def test__get_sync_gen_info(self):
492- self.assertEqual((0, ''), self.db._get_sync_gen_info('other-db'))
493- self.db._set_sync_info('other-db', 2, 'T-transaction')
494- self.assertEqual((2, 'T-transaction'),
495- self.db._get_sync_gen_info('other-db'))
496+ def test__get_replica_gen_and_trans_id(self):
497+ self.assertEqual(
498+ (0, ''), self.db._get_replica_gen_and_trans_id('other-db'))
499+ self.db._set_replica_gen_and_trans_id('other-db', 2, 'T-transaction')
500+ self.assertEqual(
501+ (2, 'T-transaction'),
502+ self.db._get_replica_gen_and_trans_id('other-db'))
503
504 def test_put_updates_transaction_log(self):
505 doc = self.db.create_doc(simple_doc)
506@@ -789,7 +794,7 @@
507
508 def test_put_doc_if_newer_replica_uid(self):
509 doc1 = self.db.create_doc(simple_doc)
510- self.db._set_sync_info('other', 1, 'T-id')
511+ self.db._set_replica_gen_and_trans_id('other', 1, 'T-id')
512 doc2 = self.make_document(doc1.doc_id, doc1.rev + '|other:1',
513 nested_doc)
514 self.db._put_doc_if_newer(doc2, save_conflict=True,
515@@ -802,7 +807,8 @@
516 self.db._put_doc_if_newer(doc2, save_conflict=True,
517 replica_uid='other', replica_gen=3,
518 replica_trans_id='T-id3')[0])
519- self.assertEqual((3, 'T-id3'), self.db._get_sync_gen_info('other'))
520+ self.assertEqual(
521+ (3, 'T-id3'), self.db._get_replica_gen_and_trans_id('other'))
522
523 def test_put_doc_if_newer_autoresolve_2(self):
524 # this is an ordering variant of _3, but that already works
525
526=== modified file 'u1db/tests/test_c_backend.py'
527--- u1db/tests/test_c_backend.py 2012-06-29 17:00:49 +0000
528+++ u1db/tests/test_c_backend.py 2012-07-03 14:37:18 +0000
529@@ -298,8 +298,8 @@
530 exc.insert_doc_from_source(doc, 10, 'T-sid')
531 self.assertGetDoc(self.db, 'doc-id', 'replica:1', tests.simple_doc,
532 False)
533- self.assertEqual((10, 'T-sid'),
534- self.db._get_sync_gen_info('source-uid'))
535+ self.assertEqual(
536+ (10, 'T-sid'), self.db._get_replica_gen_and_trans_id('source-uid'))
537 self.assertEqual(['doc-id'], exc.get_seen_ids())
538
539 def test_sync_exchange_conflicted_doc(self):
540
541=== modified file 'u1db/tests/test_http_app.py'
542--- u1db/tests/test_http_app.py 2012-06-14 23:28:58 +0000
543+++ u1db/tests/test_http_app.py 2012-07-03 14:37:18 +0000
544@@ -691,7 +691,7 @@
545 simplejson.loads(resp.body))
546
547 def test_get_sync_info(self):
548- self.db0._set_sync_info('other-id', 1, 'T-transid')
549+ self.db0._set_replica_gen_and_trans_id('other-id', 1, 'T-transid')
550 resp = self.app.get('/db0/sync-from/other-id')
551 self.assertEqual(200, resp.status)
552 self.assertEqual('application/json', resp.header('content-type'))
553@@ -709,8 +709,9 @@
554 self.assertEqual(200, resp.status)
555 self.assertEqual('application/json', resp.header('content-type'))
556 self.assertEqual({'ok': True}, simplejson.loads(resp.body))
557- self.assertEqual((2, 'T-transid'),
558- self.db0._get_sync_gen_info('other-id'))
559+ self.assertEqual(
560+ (2, 'T-transid'),
561+ self.db0._get_replica_gen_and_trans_id('other-id'))
562
563 def test_sync_exchange_send(self):
564 entries = {
565@@ -721,16 +722,19 @@
566 }
567
568 gens = []
569- _do_set_sync_info = self.db0._do_set_sync_info
570+ _do_set_replica_gen_and_trans_id = self.db0._do_set_replica_gen_and_trans_id
571
572 def set_sync_generation_witness(other_uid, other_gen, other_trans_id):
573 gens.append((other_uid, other_gen))
574- _do_set_sync_info(other_uid, other_gen, other_trans_id)
575+ _do_set_replica_gen_and_trans_id(
576+ other_uid, other_gen, other_trans_id)
577 self.assertGetDoc(self.db0, entries[other_gen]['id'],
578 entries[other_gen]['rev'],
579 entries[other_gen]['content'], False)
580
581- self.patch(self.db0, '_do_set_sync_info', set_sync_generation_witness)
582+ self.patch(
583+ self.db0, '_do_set_replica_gen_and_trans_id',
584+ set_sync_generation_witness)
585
586 args = dict(last_known_generation=0)
587 body = ("[\r\n" +
588
589=== modified file 'u1db/tests/test_https.py'
590--- u1db/tests/test_https.py 2012-06-29 16:18:14 +0000
591+++ u1db/tests/test_https.py 2012-07-03 14:37:18 +0000
592@@ -86,7 +86,8 @@
593 self.patch(http_client, 'CA_CERTS', self.cacert_pem)
594 remote_target = self.getSyncTarget('localhost', 'test')
595 remote_target.record_sync_info('other-id', 2, 'T-id')
596- self.assertEqual((2, 'T-id'), db._get_sync_gen_info('other-id'))
597+ self.assertEqual(
598+ (2, 'T-id'), db._get_replica_gen_and_trans_id('other-id'))
599
600 def test_cannot_verify_cert(self):
601 if not sys.platform.startswith('linux'):
602
603=== modified file 'u1db/tests/test_remote_sync_target.py'
604--- u1db/tests/test_remote_sync_target.py 2012-06-29 16:18:14 +0000
605+++ u1db/tests/test_remote_sync_target.py 2012-07-03 14:37:18 +0000
606@@ -171,7 +171,7 @@
607 def test_get_sync_info(self):
608 self.startServer()
609 db = self.request_state._create_database('test')
610- db._set_sync_info('other-id', 1, 'T-transid')
611+ db._set_replica_gen_and_trans_id('other-id', 1, 'T-transid')
612 remote_target = self.getSyncTarget('test')
613 self.assertEqual(('test', 0, 1, 'T-transid'),
614 remote_target.get_sync_info('other-id'))
615@@ -181,7 +181,8 @@
616 db = self.request_state._create_database('test')
617 remote_target = self.getSyncTarget('test')
618 remote_target.record_sync_info('other-id', 2, 'T-transid')
619- self.assertEqual((2, 'T-transid'), db._get_sync_gen_info('other-id'))
620+ self.assertEqual(
621+ (2, 'T-transid'), db._get_replica_gen_and_trans_id('other-id'))
622
623 def test_sync_exchange_send(self):
624 self.startServer()
625@@ -239,7 +240,8 @@
626 return_doc_cb=receive_doc)
627 self.assertGetDoc(db, 'doc-here', 'replica:1', '{"value": "here"}',
628 False)
629- self.assertEqual((10, 'T-sid'), db._get_sync_gen_info('replica'))
630+ self.assertEqual(
631+ (10, 'T-sid'), db._get_replica_gen_and_trans_id('replica'))
632 self.assertEqual([], other_changes)
633 # retry
634 trigger_ids = []
635@@ -249,7 +251,8 @@
636 return_doc_cb=receive_doc)
637 self.assertGetDoc(db, 'doc-here2', 'replica:1', '{"value": "here2"}',
638 False)
639- self.assertEqual((11, 'T-sud'), db._get_sync_gen_info('replica'))
640+ self.assertEqual(
641+ (11, 'T-sud'), db._get_replica_gen_and_trans_id('replica'))
642 self.assertEqual(2, new_gen)
643 # bounced back to us
644 self.assertEqual(
645
646=== modified file 'u1db/tests/test_sync.py'
647--- u1db/tests/test_sync.py 2012-06-29 16:18:14 +0000
648+++ u1db/tests/test_sync.py 2012-07-03 14:37:18 +0000
649@@ -441,8 +441,10 @@
650
651 def test_sync_tracks_db_generation_of_other(self):
652 self.assertEqual(0, self.sync(self.db1, self.db2))
653- self.assertEqual((0, ''), self.db1._get_sync_gen_info('test2'))
654- self.assertEqual((0, ''), self.db2._get_sync_gen_info('test1'))
655+ self.assertEqual(
656+ (0, ''), self.db1._get_replica_gen_and_trans_id('test2'))
657+ self.assertEqual(
658+ (0, ''), self.db2._get_replica_gen_and_trans_id('test1'))
659 self.assertLastExchangeLog(self.db2,
660 {'receive': {'docs': [], 'last_known_gen': 0},
661 'return': {'docs': [], 'last_gen': 0}})
662@@ -641,8 +643,8 @@
663 doc = self.db1.create_doc(simple_doc)
664 self.assertEqual(1, self.sync(self.db1, self.db2))
665 self.assertGetDoc(self.db2, doc.doc_id, doc.rev, simple_doc, False)
666- self.assertEqual(1, self.db1._get_sync_gen_info('test2')[0])
667- self.assertEqual(1, self.db2._get_sync_gen_info('test1')[0])
668+ self.assertEqual(1, self.db1._get_replica_gen_and_trans_id('test2')[0])
669+ self.assertEqual(1, self.db2._get_replica_gen_and_trans_id('test1')[0])
670 self.assertLastExchangeLog(self.db2,
671 {'receive': {'docs': [(doc.doc_id, doc.rev)],
672 'source_uid': 'test1',
673@@ -654,8 +656,8 @@
674 self.db1.create_index('test-idx', 'key')
675 self.assertEqual(0, self.sync(self.db1, self.db2))
676 self.assertGetDoc(self.db1, doc.doc_id, doc.rev, simple_doc, False)
677- self.assertEqual(1, self.db1._get_sync_gen_info('test2')[0])
678- self.assertEqual(1, self.db2._get_sync_gen_info('test1')[0])
679+ self.assertEqual(1, self.db1._get_replica_gen_and_trans_id('test2')[0])
680+ self.assertEqual(1, self.db2._get_replica_gen_and_trans_id('test1')[0])
681 self.assertLastExchangeLog(self.db2,
682 {'receive': {'docs': [], 'last_known_gen': 0},
683 'return': {'docs': [(doc.doc_id, doc.rev)],
684@@ -681,11 +683,12 @@
685 {'receive': {'docs': [], 'last_known_gen': 0},
686 'return': {'docs': [(doc.doc_id, doc.rev)],
687 'last_gen': 1}})
688- self.assertEqual(1, self.db1._get_sync_gen_info('test2')[0])
689+ self.assertEqual(1, self.db1._get_replica_gen_and_trans_id('test2')[0])
690 # c2 should not have gotten a '_record_sync_info' call, because the
691 # local database had been updated more than just by the messages
692 # returned from c2.
693- self.assertEqual((0, ''), self.db2._get_sync_gen_info('test1'))
694+ self.assertEqual(
695+ (0, ''), self.db2._get_replica_gen_and_trans_id('test1'))
696
697 def test_sync_doesnt_update_other_if_nothing_pulled(self):
698 self.db1.create_doc(simple_doc)
699@@ -696,8 +699,9 @@
700 self.fail('SyncTarget.record_sync_info was called')
701 self.assertEqual(1, self.sync(self.db1, self.db2,
702 trace_hook=no_record_sync_info))
703- self.assertEqual(1,
704- self.db2._get_sync_gen_info(self.db1._replica_uid)[0])
705+ self.assertEqual(
706+ 1,
707+ self.db2._get_replica_gen_and_trans_id(self.db1._replica_uid)[0])
708
709 def test_sync_ignores_convergence(self):
710 doc = self.db1.create_doc(simple_doc)
711@@ -840,10 +844,10 @@
712 self.sync(self.db2, self.db1)
713 self.assertEqual(
714 self.db1._get_generation_info(),
715- self.db2._get_sync_gen_info(self.db1._replica_uid))
716+ self.db2._get_replica_gen_and_trans_id(self.db1._replica_uid))
717 self.assertEqual(
718 self.db2._get_generation_info(),
719- self.db1._get_sync_gen_info(self.db2._replica_uid))
720+ self.db1._get_replica_gen_and_trans_id(self.db2._replica_uid))
721 self.sync(db3, self.db1)
722 # update on 2
723 doc2 = self.make_document('the-doc', doc1.rev, '{"a": 2}')
724@@ -879,17 +883,17 @@
725 self.sync(db3, self.db1)
726 self.assertEqual(
727 self.db1._get_generation_info(),
728- db3._get_sync_gen_info(self.db1._replica_uid))
729+ db3._get_replica_gen_and_trans_id(self.db1._replica_uid))
730 self.assertEqual(
731 db3._get_generation_info(),
732- self.db1._get_sync_gen_info(db3._replica_uid))
733+ self.db1._get_replica_gen_and_trans_id(db3._replica_uid))
734 self.sync(db3, self.db2)
735 self.assertEqual(
736 self.db2._get_generation_info(),
737- db3._get_sync_gen_info(self.db2._replica_uid))
738+ db3._get_replica_gen_and_trans_id(self.db2._replica_uid))
739 self.assertEqual(
740 db3._get_generation_info(),
741- self.db2._get_sync_gen_info(db3._replica_uid))
742+ self.db2._get_replica_gen_and_trans_id(db3._replica_uid))
743 self.assertEqual(3, len(db3.get_doc_conflicts('the-doc')))
744 doc1.set_json('{"a": 2}')
745 self.db1.put_doc(doc1)
746@@ -950,22 +954,22 @@
747 self.assertEqual(2, len(self.db2._get_transaction_log()))
748 progress1 = []
749 progress2 = []
750- _do_set_sync_info = self.db1._do_set_sync_info
751+ _do_set_replica_gen_and_trans_id = self.db1._do_set_replica_gen_and_trans_id
752
753 def set_sync_generation_witness1(other_uid, other_gen, trans_id):
754 progress1.append((other_uid, other_gen,
755 [d for d, t in self.db1._get_transaction_log()[2:]]))
756- _do_set_sync_info(other_uid, other_gen, trans_id)
757- self.patch(self.db1, '_do_set_sync_info',
758+ _do_set_replica_gen_and_trans_id(other_uid, other_gen, trans_id)
759+ self.patch(self.db1, '_do_set_replica_gen_and_trans_id',
760 set_sync_generation_witness1)
761
762- _do_set_sync_info2 = self.db2._do_set_sync_info
763+ _do_set_replica_gen_and_trans_id2 = self.db2._do_set_replica_gen_and_trans_id
764
765 def set_sync_generation_witness2(other_uid, other_gen, trans_id):
766 progress2.append((other_uid, other_gen,
767 [d for d, t in self.db2._get_transaction_log()[2:]]))
768- _do_set_sync_info2(other_uid, other_gen, trans_id)
769- self.patch(self.db2, '_do_set_sync_info',
770+ _do_set_replica_gen_and_trans_id2(other_uid, other_gen, trans_id)
771+ self.patch(self.db2, '_do_set_replica_gen_and_trans_id',
772 set_sync_generation_witness2)
773
774 db2_url = self.getURL('test2')

Subscribers

People subscribed via source and target branches