Bug 615410 - Use different annotations for parent and predecessor. r=mconnor
☠☠ backed out by 84fe21efcb57 ☠ ☠
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Mon, 06 Dec 2010 15:51:48 -0800
changeset 58762 81d8bf53ab01179d684cb78c4384c96eaa5b01fd
parent 58761 3e74c1c15b63bece3bef6664d19cb69cb39eefa6
child 58763 1b2d4ba850a9d8d75cc0efc031d227b4365ef741
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersmconnor
bugs615410
Bug 615410 - Use different annotations for parent and predecessor. r=mconnor The old annotations will no longer be valid because they point to a different kind of GUID. Since we're using our own GUID system now, we also don't have to munge predecessor and parent GUIDs before setting them.
services/sync/modules/engines/bookmarks.js
--- a/services/sync/modules/engines/bookmarks.js
+++ b/services/sync/modules/engines/bookmarks.js
@@ -39,18 +39,18 @@
 
 const EXPORTED_SYMBOLS = ['BookmarksEngine', 'BookmarksSharingManager'];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 const GUID_ANNO = "sync/guid";
-const PARENT_ANNO = "weave/parent";
-const PREDECESSOR_ANNO = "weave/predecessor";
+const PARENT_ANNO = "sync/parent";
+const PREDECESSOR_ANNO = "sync/predecessor";
 const SERVICE_NOT_SUPPORTED = "Service not supported on this platform";
 const FOLDER_SORTINDEX = 1000000;
 
 try {
   Cu.import("resource://gre/modules/PlacesUtils.jsm");
 }
 catch(ex) {
   Cu.import("resource://gre/modules/utils.js");
@@ -399,41 +399,32 @@ BookmarksStore.prototype = {
     // Do some post-processing if we have an item
     let itemId = this.idForGUID(record.id);
     if (itemId > 0) {
       // Move any children that are looking for this folder as a parent
       if (record.type == "folder")
         this._reparentOrphans(itemId);
 
       // Create an annotation to remember that it needs a parent
-      // XXX Work around Bug 510628 by prepending parenT
       if (record._orphan)
-        Utils.anno(itemId, PARENT_ANNO, "T" + parentGUID);
+        Utils.anno(itemId, PARENT_ANNO, parentGUID);
       // It's now in the right folder, so move annotated items behind this
       else
         this._attachFollowers(itemId);
 
       // Create an annotation if we have a predecessor but no position
-      // XXX Work around Bug 510628 by prepending predecessoR
       if (predGUID != null && record._insertPos == Svc.Bookmark.DEFAULT_INDEX)
-        Utils.anno(itemId, PREDECESSOR_ANNO, "R" + predGUID);
+        Utils.anno(itemId, PREDECESSOR_ANNO, predGUID);
     }
   },
 
   /**
    * Find all ids of items that have a given value for an annotation
    */
   _findAnnoItems: function BStore__findAnnoItems(anno, val) {
-    // XXX Work around Bug 510628 by prepending parenT
-    if (anno == PARENT_ANNO)
-      val = "T" + val;
-    // XXX Work around Bug 510628 by prepending predecessoR
-    else if (anno == PREDECESSOR_ANNO)
-      val = "R" + val;
-
     return Svc.Annos.getItemsWithAnnotation(anno, {}).filter(function(id)
       Utils.anno(id, anno) == val);
   },
 
   /**
    * For the provided parent item, attach its children to it
    */
   _reparentOrphans: function _reparentOrphans(parentId) {
@@ -682,20 +673,20 @@ BookmarksStore.prototype = {
   },
 
   changeItemID: function BStore_changeItemID(oldID, newID) {
     // Remember the GUID change for incoming records
     this.aliases[oldID] = newID;
 
     // Update any existing annotation references
     this._findAnnoItems(PARENT_ANNO, oldID).forEach(function(itemId) {
-      Utils.anno(itemId, PARENT_ANNO, "T" + newID);
+      Utils.anno(itemId, PARENT_ANNO, newID);
     }, this);
     this._findAnnoItems(PREDECESSOR_ANNO, oldID).forEach(function(itemId) {
-      Utils.anno(itemId, PREDECESSOR_ANNO, "R" + newID);
+      Utils.anno(itemId, PREDECESSOR_ANNO, newID);
     }, this);
 
     // Make sure there's an item to change GUIDs
     let itemId = this.idForGUID(oldID);
     if (itemId <= 0)
       return;
 
     this._log.debug("Changing GUID " + oldID + " to " + newID);
@@ -987,35 +978,33 @@ BookmarksStore.prototype = {
     }
 
     return index;
   },
 
   _getParentGUIDForId: function BStore__getParentGUIDForId(itemId) {
     // Give the parent annotation if it exists
     try {
-      // XXX Work around Bug 510628 by removing prepended parenT
-      return Utils.anno(itemId, PARENT_ANNO).slice(1);
+      return Utils.anno(itemId, PARENT_ANNO);
     }
     catch(ex) {}
 
     let parentid = this._bms.getFolderIdForItem(itemId);
     if (parentid == -1) {
       this._log.debug("Found orphan bookmark, reparenting to unfiled");
       parentid = this._bms.unfiledBookmarksFolder;
       this._bms.moveItem(itemId, parentid, -1);
     }
     return this.GUIDForId(parentid);
   },
 
   _getPredecessorGUIDForId: function BStore__getPredecessorGUIDForId(itemId) {
     // Give the predecessor annotation if it exists
     try {
-      // XXX Work around Bug 510628 by removing prepended predecessoR
-      return Utils.anno(itemId, PREDECESSOR_ANNO).slice(1);
+      return Utils.anno(itemId, PREDECESSOR_ANNO);
     }
     catch(ex) {}
 
     // Figure out the predecessor, unless it's the first item
     let itemPos = Svc.Bookmark.getItemIndex(itemId);
     if (itemPos == 0)
       return;