Merge lp:~urbanape/bindwood/fix-512363 into lp:bindwood

Proposed by Zachery Bir
Status: Merged
Approved by: Joshua Blount
Approved revision: 24
Merged at revision: not available
Proposed branch: lp:~urbanape/bindwood/fix-512363
Merge into: lp:bindwood
Diff against target: 544 lines (+166/-86)
1 file modified
modules/bindwood.jsm (+166/-86)
To merge this branch: bzr merge lp:~urbanape/bindwood/fix-512363
Reviewer Review Type Date Requested Status
Joshua Blount (community) Approve
Joshua Hoover (community) ran branch and verified functionality Approve
Review via email: mp+22677@code.launchpad.net

Description of the change

This branch was created because during testing of the 1.0 codebase, subsequent clients were not behaving properly, and the merge of old, existing, and new bookmarks was not being done properly. In testing this branch, at least one error was found due to the migration code. The most relevant part of the diff is the following, as the vast bulk of the diff is cleaning up long lines:

- // Ensure that any remote folders have their .children
- // populated
- if (doc.record_type == Bindwood.TYPE_FOLDER) {
- doc.children = Bindwood.getUUIDsFromFolder(itemId);
- }
-
             // add to additional
             additional.push(doc);
             Bindwood.writeMessage(
@@ -578,15 +574,29 @@
         }

         for (var i = 0; i < additional.length; i++) {
+ var doc = additional[i];
+ Bindwood.writeMessage(
+ "Preparing to push back " + doc.title || doc.record_type);
+ // Ensure that any remote folders have their .children
+ // populated, and in particular make sure that we've already
+ // modified their children's annotations/uuids
+ if (doc.record_type == Bindwood.TYPE_FOLDER) {
+ var itemId = Bindwood.itemIdForUUID(doc._id);
+ doc.children = Bindwood.getUUIDsFromFolder(itemId);
+ Bindwood.writeMessage(
+ "Folder needed updating, calculated children: " +
+ doc.children);
+ }
+
             try {
- var response = Bindwood.couch.save(additional[i]);
+ var response = Bindwood.couch.save(doc);
                 // We can avoid having to process this revision when we
                 // pull it later
                 Bindwood.seen_revisions[response.rev] = true;
             } catch(e) {
                 Bindwood.writeError(
                     "Problem saving record to CouchDB; record is " +
- JSON.stringify(additional[i]) + ": ", e);
+ JSON.stringify(doc + ": ", e));
             }
         }
     },

To post a comment you must log in.
Revision history for this message
Zachery Bir (urbanape) wrote :
Download full text (5.2 KiB)

Some downloads
==============

  * lp:~urbanape/bindwood/fix-512363

    The branch under test

  * http://chinstrap.canonical.com/~zbir/bindwood-0.5.tar.gz

    A modified version of 0.5 that will work with Firefox 3.6

  * http://chinstrap.canonical.com/~zbir/profiles.ini

    A Firefox profiles.ini file that will point to our test profile

  * http://chinstrap.canonical.com/~zbir/00-pristine.tar.gz

  * http://chinstrap.canonical.com/~zbir/01-first-client.tar.gz

  * http://chinstrap.canonical.com/~zbir/02-second-client.tar.gz

    Three complete profile directories, all tarred up. The ones to test
    are 01-first-client and 02-second-client, both built from
    00-pristine. They all expand to the same directory: 6yz8p1ca.default,
    so only one can be in play at a time. This is useful, though for
    performing the different tests.

General testing strategy
========================

  All there tests will work best if you can test against a throwaway
  CouchDB. The older 0.5 branch can't target an alternate DB at startup,
  while the newer 1.0+ branches can, so it's easier if all tests can be
  done against a bookmarks DB that is relatively disposable.

  My setup is as follows:

    * ~/dev/bindwood/

      A directory that holds all my branches in development

    * ~/dev/bindwood/bindwood-0.5

      The modified version of the 0.5 release that works with Firefox 3.6

    * ~/dev/bindwood/fix-512363

      A bzr branched copy of the branch under test

    * ~/dev/bindwood/current

      A symlink to the branch I'm currently working on

    * ~/.mozilla/firefox/

      I backed up my copy of this directory and started fresh to create
      the aforementioned profiles. You'll probably want to do the same.

      I put all those tarballs and the profiles.ini in this directory,
      and I can blow away the 6yz8p1ca.default directory at any time and
      expand any of the tarballs I need. The following test scripts
      assume you have your ~/.mozilla/firefox directory set up like this.

    * ubuntuone-couchdb-query script

      Located at http://www.freedesktop.org/wiki/Specifications/desktopcouch/Documentation/Troubleshooting?action=AttachFile&do=view&target=ubuntuone-couchdb-query - useful for blowing away a remote bookmarks database if necessary:

        python ubuntuone-couchdb-query --http-method=DELETE bookmarks

      It won't ask for confirmation, so be sure you want to do this.

Testing migration
=================

  This isn't entirely necessary for testing fix-512363, but I'm including
  it here for completeness' sake.

  1) Symlink the bindwood-0.5 directory to current.

  2) Expand the 01-first-client.tar.gz profile

  3) Add a symlink to its extensions directory to ~/dev/bindwood/current
     called '<email address hidden>':

     $ ln -s ~/dev/bindwood/current <email address hidden>

  4) Ensure there is no bookmarks database in your desktopcouch

  5) Start Firefox. Check your DC futon and watch for a bookmarks
     database. There should be 30 records in it.

  6) Quit Firefox.

  7) Swap the 'current' symlink to fix-512363

  8) Start Firefox. You'll get a popup window explaining that it will
     migrate the bookmark re...

Read more...

Revision history for this message
Joshua Hoover (joshuahoover) wrote :

Approved. Ran through Zac's steps on two Lucid VMs with all the latest updates as of today. Bookmarks were saved properly and merged on the second VM as expected.

review: Approve (ran branch and verified functionality)
Revision history for this message
Joshua Blount (jblount) wrote :

That was a lot of steps, but bookmarks seem to be doing the right thing. Well done with the instructions Monsieur Ape!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/bindwood.jsm'
2--- modules/bindwood.jsm 2010-03-30 10:34:18 +0000
3+++ modules/bindwood.jsm 2010-04-02 03:33:20 +0000
4@@ -497,7 +497,9 @@
5 },
6
7 migrateOlderBookmarkRecords: function() {
8- Bindwood.writeMessage("We're an older client. Let's migrate the remote records and re-sync.");
9+ Bindwood.writeMessage(
10+ "We're an older client. " +
11+ "Let's migrate the remote records and re-sync.");
12
13 var additional = [];
14 var all_docs = Bindwood.couch.allDocs();
15@@ -565,12 +567,6 @@
16 // Ensure we're dealing with the proper record type on Migrate.
17 doc = Bindwood.decorateRecordByType(doc, itemId);
18
19- // Ensure that any remote folders have their .children
20- // populated
21- if (doc.record_type == Bindwood.TYPE_FOLDER) {
22- doc.children = Bindwood.getUUIDsFromFolder(itemId);
23- }
24-
25 // add to additional
26 additional.push(doc);
27 Bindwood.writeMessage(
28@@ -578,15 +574,29 @@
29 }
30
31 for (var i = 0; i < additional.length; i++) {
32+ var doc = additional[i];
33+ Bindwood.writeMessage(
34+ "Preparing to push back " + doc.title || doc.record_type);
35+ // Ensure that any remote folders have their .children
36+ // populated, and in particular make sure that we've already
37+ // modified their children's annotations/uuids
38+ if (doc.record_type == Bindwood.TYPE_FOLDER) {
39+ var itemId = Bindwood.itemIdForUUID(doc._id);
40+ doc.children = Bindwood.getUUIDsFromFolder(itemId);
41+ Bindwood.writeMessage(
42+ "Folder needed updating, calculated children: " +
43+ doc.children);
44+ }
45+
46 try {
47- var response = Bindwood.couch.save(additional[i]);
48+ var response = Bindwood.couch.save(doc);
49 // We can avoid having to process this revision when we
50 // pull it later
51 Bindwood.seen_revisions[response.rev] = true;
52 } catch(e) {
53 Bindwood.writeError(
54 "Problem saving record to CouchDB; record is " +
55- JSON.stringify(additional[i]) + ": ", e);
56+ JSON.stringify(doc + ": ", e));
57 }
58 }
59 },
60@@ -596,7 +606,8 @@
61 "We're a subsequent client. Let's merge the remote and the local.");
62
63 // get the remote root from Couch.
64- var remote_root = Bindwood.couch.open('root_' + Bindwood.currentProfile);
65+ var remote_root = Bindwood.couch.open(
66+ 'root_' + Bindwood.currentProfile);
67 var local_roots = [bookmarksService.toolbarFolder,
68 bookmarksService.bookmarksMenuFolder,
69 bookmarksService.unfiledBookmarksFolder];
70@@ -604,7 +615,10 @@
71 var records_needing_pushing = [];
72
73 for (var i = 0; i < local_roots.length; i++) {
74- Bindwood.syncRemoteAndLocal(remote_root.children[i], local_roots[i], records_needing_pushing);
75+ Bindwood.syncRemoteAndLocal(
76+ remote_root.children[i],
77+ local_roots[i],
78+ records_needing_pushing);
79 }
80
81 for (var i = 0; i < records_needing_pushing.length; i++) {
82@@ -622,7 +636,9 @@
83 },
84
85 syncRemoteAndLocal: function(remote_folder, local_folder, accum) {
86- Bindwood.writeMessage("Syncing remote folder: " + remote_folder + " to local folder: " + local_folder);
87+ Bindwood.writeMessage(
88+ "Syncing remote folder: " + remote_folder +
89+ " to local folder: " + local_folder);
90 var local_needs_pushing = false;
91
92 // get the local folder's root, and open it for iteration
93@@ -634,35 +650,45 @@
94 var remote_children = remote.children;
95 Bindwood.writeMessage("Beginning to walk remote children");
96 for (var i = 0; i < remote_children.length; i++) {
97+ Bindwood.writeMessage(
98+ "Getting remote child: " + remote_children[i]);
99 var remote_child = Bindwood.couch.open(remote_children[i]);
100 var local_child;
101 var found_local = false;
102
103- Bindwood.writeMessage("Looking for record type: " + remote_child.record_type +
104- " identified by " + remote_child.record_type != Bindwood.TYPE_SEPARATOR ? remote_child.title : "being a separator");
105+ Bindwood.writeMessage(
106+ "Looking for record type: " + remote_child.record_type +
107+ " identified by " +
108+ (remote_child.record_type != Bindwood.TYPE_SEPARATOR ?
109+ remote_child.title :
110+ "being a separator"));
111
112 // does my local toolbarFolder have this child anywhere in it?
113 for (var j = 0; j < local.childCount; j++) {
114 local_child = local.getChild(j);
115
116- // Check to see whether we're testing a separator (which has no title)
117- // or whether we're testing the same type and title
118- if ((Bindwood.sameType(local_child, remote_child) &&
119- remote_child.record_type == Bindwood.TYPE_SEPARATOR) ||
120- (Bindwood.sameType(local_child, remote_child) &&
121+ // Check to see whether we're testing a separator (which
122+ // has no title) or whether we're testing the same type
123+ // and title
124+ if (Bindwood.sameType(local_child, remote_child) &&
125+ (remote_child.record_type == Bindwood.TYPE_SEPARATOR ||
126 Bindwood.sameTitle(local_child, remote_child))) {
127 found_local = true;
128 Bindwood.writeMessage("Found the record.");
129- Bindwood.annotateItemWithUUID(local_child.itemId, remote_child._id);
130- // If we're dealing with a folder, we'll process it recursively,
131- // and the only other thing we'd impose would be the title,
132- // which already matches..
133+ Bindwood.annotateItemWithUUID(
134+ local_child.itemId, remote_child._id);
135+ // If we're dealing with a folder, we'll process it
136+ // recursively, and the only other thing we'd impose
137+ // would be the title, which already matches..
138 if (remote_child.record_type != Bindwood.TYPE_FOLDER) {
139 Bindwood.processCouchRecord(remote_child, null, null);
140 }
141- if (i != j) { // if yes, but in a different location
142- // Move the local to the proper index within the same folder.
143- Bindwood.writeMessage("Record isn't in the same location as remote, moving it.");
144+ if (i != j) {
145+ // If yes, but in a different location, move the
146+ // local to the proper index within the same
147+ // folder.
148+ Bindwood.writeMessage(
149+ "Moving local record to same index as remote.");
150 Bindwood.makeLocalChangeOnly(
151 function() {
152 bookmarksService.moveItem(
153@@ -675,18 +701,25 @@
154 }
155
156 if (!found_local) {
157- // Add the record locally, annotate it, and place it in the correct index.
158- // Add current local folder as one that needs to be pushed back (changing its children)
159-
160- Bindwood.writeMessage("Remote record doesn't exist here, recreating it in " + local_folder + " at index " + i + ".");
161+ // Add the record locally, annotate it, and place it in
162+ // the correct index.
163+
164+ // Add current local folder as one that needs to be
165+ // pushed back (changing its children)
166+
167+ Bindwood.writeMessage(
168+ "Remote record doesn't exist here, recreating it in " +
169+ local_folder + " at index " + i + ".");
170 Bindwood.processCouchRecord(remote_child, local_folder, i);
171 local_needs_pushing = true;
172 }
173
174 // is the child a folder?
175 if (remote_child.record_type == Bindwood.TYPE_FOLDER) {
176- // Recurse into the function with remote id and local folder id
177- Bindwood.syncRemoteAndLocal(remote_child._id, local_child.itemId, accum);
178+ // Recurse into the function with remote id and local
179+ // folder id
180+ Bindwood.syncRemoteAndLocal(
181+ remote_child._id, local_child.itemId, accum);
182 }
183 }
184
185@@ -744,11 +777,14 @@
186 var items = annotationService.getItemsWithAnnotation(
187 Bindwood.annotationKey, {});
188 var num_items = items.length;
189- Bindwood.writeMessage("Found " + num_items + " records with the annotation key");
190+ Bindwood.writeMessage(
191+ "Found " + num_items + " records with the annotation key");
192 for (var i = 0; i < items.length; i++) {
193 Bindwood.writeMessage("Item #" + i + ": ItemId: " + items[i]);
194- var anno = annotationService.getItemAnnotation(items[i], Bindwood.annotationKey);
195- Bindwood.writeMessage("Annotation on " + items[i] + ": " + anno);
196+ var anno = annotationService.getItemAnnotation(
197+ items[i], Bindwood.annotationKey);
198+ Bindwood.writeMessage(
199+ "Annotation on " + items[i] + ": " + anno);
200 if (anno == uuid) {
201 var itemId = items[i];
202 Bindwood.uuidItemIdMap[uuid] = itemId;
203@@ -892,7 +928,8 @@
204 }
205 }
206 Bindwood.writeMessage(
207- "Done collecting children. Folder's children is now: " + JSON.stringify(folder_record.children));
208+ "Done collecting children. Folder's children is now: " +
209+ JSON.stringify(folder_record.children));
210 folderRoot.containerOpen = false;
211 Bindwood.records.push(folder_record);
212 return folder_record;
213@@ -961,7 +998,8 @@
214 // this record is not in CouchDB, so write it
215 try {
216 var response = Bindwood.couch.save(record);
217- // We can avoid having to process this revision when we pull it later
218+ // We can avoid having to process this revision when
219+ // we pull it later
220 Bindwood.seen_revisions[response.rev] = true;
221 } catch(e) {
222 Bindwood.writeError(
223@@ -971,7 +1009,8 @@
224 } else {
225 // record is already in CouchDB, so do nothing
226 Bindwood.writeMessage(
227- "This record (" + record._id + ") is already in Couch, skipping");
228+ "This record (" + record._id +
229+ ") is already in Couch, skipping");
230 }
231 }
232 Bindwood.latest_modified = Bindwood.setLatestModified(
233@@ -1002,7 +1041,8 @@
234
235 // reschedule ourself
236 try {
237- Bindwood.pull_changes_timer.initWithCallback(repeater, 30000, Ci.nsITimer.TYPE_REPEATING_SLACK);
238+ Bindwood.pull_changes_timer.initWithCallback(
239+ repeater, 30000, Ci.nsITimer.TYPE_REPEATING_SLACK);
240 } catch(e) {
241 Bindwood.writeError("Problem setting up repeater.", e);
242 }
243@@ -1016,7 +1056,9 @@
244 Bindwood.status_timer.cancel();
245 var div = Bindwood.statusWindow.document.getElementById('status');
246 var dots = div.innerHTML;
247- div.innerHTML = dots + ' Finished, you can close this window and proceed. Thanks for your patience.';
248+ div.innerHTML = (dots +
249+ "<br/><br/> Finished, you can close this window and proceed. " +
250+ "Thanks for your patience.");
251 },
252
253 pullRecords: function() {
254@@ -1053,14 +1095,17 @@
255 // design doc
256 if (recordid.indexOf('root_') === 0 ||
257 recordid.indexOf('_design') === 0) {
258- Bindwood.writeMessage("Root profile or design doc, skipping...");
259+ Bindwood.writeMessage(
260+ "Root profile or design doc, skipping...");
261 continue;
262 }
263
264 // Skip any revisions we've already seen (because we just
265 // put them there)
266 if (Bindwood.seen_revisions[revno]) {
267- Bindwood.writeMessage("We've seen this revision (" + revno + ") before, when we created it.");
268+ Bindwood.writeMessage(
269+ "We've seen this revision (" + revno +
270+ ") before, when we created it.");
271 delete Bindwood.seen_revisions[revno];
272 continue;
273 }
274@@ -1068,7 +1113,8 @@
275 var record = Bindwood.couch.open(recordid);
276
277 if (!Bindwood.recordInCurrentProfile(record)) {
278- Bindwood.writeMessage("Record isn't in our current profile. Skipping...");
279+ Bindwood.writeMessage(
280+ "Record isn't in our current profile. Skipping...");
281 continue;
282 }
283
284@@ -1084,7 +1130,9 @@
285 " attempting to delete local copy.");
286 Bindwood.deleteLocalRecord(record);
287 });
288- continue; // Don't bother continuing to process anything further in this revision
289+ // Don't bother continuing to process anything further in
290+ // this revision
291+ continue;
292 }
293
294 Bindwood.processCouchRecord(record, null, null);
295@@ -1127,31 +1175,37 @@
296 var aParent = aParent ? aParent : Bindwood.scratch_folder;
297 var aIndex = aIndex ? aIndex : -1;
298
299- Bindwood.writeMessage("Processing Couch Record: " + record + " placing it in " + aParent + " at location " + aIndex);
300+ Bindwood.writeMessage(
301+ "Processing Couch Record: " + record + " placing it in " +
302+ aParent + " at location " + aIndex);
303
304 switch(record.record_type) {
305 case Bindwood.TYPE_BOOKMARK:
306 Bindwood.makeLocalChangeOnly(
307 function() {
308- Bindwood.processCouchBookmarkRevision(record, aParent, aIndex);
309+ Bindwood.processCouchBookmarkRevision(
310+ record, aParent, aIndex);
311 });
312 break;
313 case Bindwood.TYPE_FOLDER:
314 Bindwood.makeLocalChangeOnly(
315 function() {
316- Bindwood.processCouchFolderRevision(record, aParent, aIndex);
317+ Bindwood.processCouchFolderRevision(
318+ record, aParent, aIndex);
319 });
320 break;
321 case Bindwood.TYPE_FEED:
322 Bindwood.makeLocalChangeOnly(
323 function() {
324- Bindwood.processCouchFeedRevision(record, aParent, aIndex);
325+ Bindwood.processCouchFeedRevision(
326+ record, aParent, aIndex);
327 });
328 break;
329 case Bindwood.TYPE_SEPARATOR:
330 Bindwood.makeLocalChangeOnly(
331 function() {
332- Bindwood.processCouchSeparatorRevision(record, aParent, aIndex);
333+ Bindwood.processCouchSeparatorRevision(
334+ record, aParent, aIndex);
335 });
336 break;
337 default:
338@@ -1161,9 +1215,10 @@
339
340 processCouchBookmarkRevision: function(record, aParent, aIndex) {
341 // Could be an add or change revision. Delete was handled earlier.
342- // If it's an addition (we can't resolve its _id to be one of our itemIds),
343- // add it to the Desktop Couch folder in unfiled.
344- Bindwood.writeMessage("Processing bookmark record: " + JSON.stringify(record));
345+ // If it's an addition (we can't resolve its _id to be one of our
346+ // itemIds), add it to the Desktop Couch folder in unfiled.
347+ Bindwood.writeMessage(
348+ "Processing bookmark record: " + JSON.stringify(record));
349 var itemId = Bindwood.itemIdForUUID(record._id);
350 if (itemId) {
351 // It's a change. Stamp everything remote on the local bookmark
352@@ -1183,38 +1238,50 @@
353 },
354
355 processCouchFolderRevision: function(record, aParent, aIndex) {
356- // Could be an add or change revision. Delete was handled earlier.
357- // If it's an addition (we can't resolve its _id to be one of our itemIds),
358- // add it to the Desktop Couch folder in unfiled.
359- Bindwood.writeMessage("Processing folder record: " + JSON.stringify(record));
360+ // Could be an add or change revision. Delete was handled
361+ // earlier. If it's an addition (we can't resolve its _id to be
362+ // one of our itemIds), add it to the Desktop Couch folder in
363+ // unfiled.
364+ Bindwood.writeMessage(
365+ "Processing folder record: " + JSON.stringify(record));
366 var itemId = Bindwood.itemIdForUUID(record._id);
367 if (itemId) {
368- // It's a change. Stamp remote title on the folder, and deal with any
369- // changed children.
370+ // It's a change. Stamp remote title on the folder, and deal
371+ // with any changed children.
372 Bindwood.noteStartTime('Shuffling folder children');
373 bookmarksService.setItemTitle(itemId, record.title);
374- // Iterate through our current folder children, and compare with remote.
375- // Move all local children to the scratch folder, then move them back
376- // in the order of the remote children.
377+ // Iterate through our current folder children, and compare
378+ // with remote. Move all local children to the scratch
379+ // folder, then move them back in the order of the remote
380+ // children.
381 var local_children = Bindwood.getUUIDsFromFolder(itemId);
382- Bindwood.writeMessage("Moving local children " + JSON.stringify(local_children) + " to scratch folder");
383+ Bindwood.writeMessage(
384+ "Moving local children " + JSON.stringify(local_children) +
385+ " to scratch folder");
386 for (var i = 0; i<local_children.length; i++) {
387 var child = local_children[i];
388 var child_itemId = Bindwood.itemIdForUUID(child);
389 try {
390- bookmarksService.moveItem(child_itemId, Bindwood.scratch_folder, -1);
391+ bookmarksService.moveItem(
392+ child_itemId, Bindwood.scratch_folder, -1);
393 } catch(e) {
394- Bindwood.writeError("Problem moving item to scratch folder: " + JSON.stringify(e), e);
395+ Bindwood.writeError(
396+ "Problem moving item to scratch folder: " +
397+ JSON.stringify(e), e);
398 }
399 }
400- Bindwood.writeMessage("Moving children identified by record " + JSON.stringify(record.children) + " to this folder");
401+ Bindwood.writeMessage(
402+ "Moving children identified by record " +
403+ JSON.stringify(record.children) + " to this folder");
404 for (var j = 0; j<record.children.length; j++) {
405 var new_child = record.children[j];
406 var new_child_itemId = Bindwood.itemIdForUUID(new_child);
407 try {
408 bookmarksService.moveItem(new_child_itemId, itemId, -1);
409 } catch(e) {
410- Bindwood.writeError("Problem moving item from scratch folder: " + JSON.stringify(e), e);
411+ Bindwood.writeError(
412+ "Problem moving item from scratch folder: " +
413+ JSON.stringify(e), e);
414 }
415 }
416 Bindwood.noteEndTime('Shuffling folder children');
417@@ -1230,10 +1297,12 @@
418 },
419
420 processCouchFeedRevision: function(record, aParent, aIndex) {
421- // Could be an add or change revision. Delete was handled earlier.
422- // If it's an addition (we can't resolve its _id to be one of our itemIds),
423- // add it to the Desktop Couch folder in unfiled.
424- Bindwood.writeMessage("Processing feed record: " + JSON.stringify(record));
425+ // Could be an add or change revision. Delete was handled
426+ // earlier. If it's an addition (we can't resolve its _id to be
427+ // one of our itemIds), add it to the Desktop Couch folder in
428+ // unfiled.
429+ Bindwood.writeMessage(
430+ "Processing feed record: " + JSON.stringify(record));
431 var itemId = Bindwood.itemIdForUUID(record._id);
432 if (itemId) {
433 // It's a change. Stamp everything remote on the local bookmark
434@@ -1256,11 +1325,12 @@
435 },
436
437 processCouchSeparatorRevision: function(record, aParent, aIndex) {
438- // Should only be an add revision. There's nothing to change, and delete was
439- // handled earlier.
440- // If it's an addition (we can't resolve its _id to be one of our itemIds),
441- // add it to the Desktop Couch folder in unfiled.
442- Bindwood.writeMessage("Processing separator record: " + JSON.stringify(record));
443+ // Should only be an add revision. There's nothing to change, and
444+ // delete was handled earlier. If it's an addition (we can't
445+ // resolve its _id to be one of our itemIds), add it to the
446+ // Desktop Couch folder in unfiled.
447+ Bindwood.writeMessage(
448+ "Processing separator record: " + JSON.stringify(record));
449 var itemId = Bindwood.itemIdForUUID(record._id);
450 if (!itemId) {
451 // There's nothing to change about a separator, so...
452@@ -1341,7 +1411,8 @@
453 Observer: {
454 // An nsINavBookmarkObserver
455 onItemAdded: function(aItemId, aFolder, aIndex) {
456- Bindwood.writeMessage("onItemAdded: called when push is " + Bindwood.push);
457+ Bindwood.writeMessage(
458+ "onItemAdded: called when push is " + Bindwood.push);
459 // An item has been added, so we create a blank entry
460 // in Couch with our local itemId attached.
461 if (!Bindwood.itemWeCareAbout(aItemId)) {
462@@ -1380,7 +1451,8 @@
463 bookmarksService.getItemLastModified(aItemId));
464 },
465 onBeforeItemRemoved: function(aItemId) {
466- Bindwood.writeMessage("onBeforeItemRemoved: called when push is " + Bindwood.push);
467+ Bindwood.writeMessage(
468+ "onBeforeItemRemoved: called when push is " + Bindwood.push);
469 // A bookmark has been removed. This is called before it's
470 // been removed locally, though we're passed the itemId,
471 // which we use to delete from Couch.
472@@ -1440,7 +1512,8 @@
473 }
474 },
475 onItemRemoved: function(aItemId, aFolder, aIndex) {
476- Bindwood.writeMessage("onItemRemoved: called when push is " + Bindwood.push);
477+ Bindwood.writeMessage(
478+ "onItemRemoved: called when push is " + Bindwood.push);
479 // This only happens locally, so there's never a need to push
480 if (!Bindwood.itemWeCareAbout(aItemId)) {
481 Bindwood.writeMessage("Ignoring this remove event");
482@@ -1455,7 +1528,8 @@
483 "Removed annotations from bookmark identified by: " + aItemId);
484 },
485 onItemChanged: function(aItemId, aProperty, aIsAnnotationProperty, aValue) {
486- Bindwood.writeMessage("onItemChanged: called when push is " + Bindwood.push);
487+ Bindwood.writeMessage(
488+ "onItemChanged: called when push is " + Bindwood.push);
489 // A property of a bookmark has changed. On multiple
490 // property updates, this will be called multiple times,
491 // once per property (i.e., for title and URI)
492@@ -1501,9 +1575,11 @@
493 },
494
495 onItemMoved: function(aItemId, aOldParent, aOldIndex, aNewParent, aNewIndex) {
496- Bindwood.writeMessage("onItemMoved: called when push is " + Bindwood.push);
497- Bindwood.writeMessage(
498- "The item: " + aItemId + " was moved from (" + aOldParent + ", " + aOldIndex +
499+ Bindwood.writeMessage(
500+ "onItemMoved: called when push is " + Bindwood.push);
501+ Bindwood.writeMessage(
502+ "The item: " + aItemId + " was moved from (" +
503+ aOldParent + ", " + aOldIndex +
504 ") to (" + aNewParent + ", " + aNewIndex + ")"
505 );
506 switch (Bindwood.push) {
507@@ -1515,7 +1591,8 @@
508 var uuid = Bindwood.uuidForItemId(aItemId);
509 var old_parent_uuid = Bindwood.uuidForItemId(aOldParent);
510 var old_parent_doc = Bindwood.couch.open(old_parent_uuid);
511- old_parent_doc.children = Bindwood.getUUIDsFromFolder(aOldParent);
512+ old_parent_doc.children = Bindwood.getUUIDsFromFolder(
513+ aOldParent);
514 try {
515 var response = Bindwood.couch.save(old_parent_doc);
516 Bindwood.seen_revisions[response.rev] = true;
517@@ -1526,13 +1603,15 @@
518 if (aOldParent != aNewParent) {
519 var new_parent_uuid = Bindwood.uuidForItemId(aNewParent);
520 var new_parent_doc = Bindwood.couch.open(new_parent_uuid);
521- new_parent_doc.children = Bindwood.getUUIDsFromFolder(aNewParent);
522+ new_parent_doc.children = Bindwood.getUUIDsFromFolder(
523+ aNewParent);
524 try {
525 var response = Bindwood.couch.save(new_parent_doc);
526 Bindwood.seen_revisions[response.rev] = true;
527 } catch(e) {
528 Bindwood.writeError(
529- "Problem saving updated new parent doc to Couch: ", e);
530+ "Problem saving updated new parent doc to Couch: ",
531+ e);
532 }
533 }
534 break;
535@@ -1540,7 +1619,8 @@
536 break;
537 }
538
539- // Set the latest modified to the greatest of aItemId, aOldParent, or aNewParent's last_modified
540+ // Set the latest modified to the greatest of aItemId,
541+ // aOldParent, or aNewParent's last_modified
542 Bindwood.setLatestModified(
543 [bookmarksService.getItemLastModified(aItemId),
544 bookmarksService.getItemLastModified(aOldParent),

Subscribers

People subscribed via source and target branches