Foxmarks: Merge Algorithm
From Foxmarks Wiki
Here's the proposed algorithm for handling a merge of two disparate sets of bookmarks.
- Push the respective roots of the native and foreign sets onto the stack.
- While there's anything remaining on the stack:
- pop the topmost element on the stack. This element contains resource id's for a native and foreign folder that we've decided are matches.
- Construct a list of children in each of the foreign and native folders.
- For each item in the foreign folder, try to match it against an item in the native folder. If unsuccessful, append the item (including its recursive children if it's a folder) to the native folder. If we do find a match:
- If the match is a folder, append the matches to the stack.
- Remove the item from the list of items in the native folder to prevent it from being the target of a match a second time.
Some details:
The definition of a match depends on the type of item involved:
- If the item is a Folder, a match depends on the folder name and description. Both must be identical to be a match.
- If the item is a Bookmark, a match depends on the URL. If the URL matches, they are a match. Any other of the following fields that don't match are added to the description field of the native item: name, description, keyword. The webpanel boolean remains as set in the native set.
- If the item is a Separator, a match depends on the name.
When we append an item to the native set:
- We check to see if it's already been dirtied. If not, we just do the append and set the dirty bit.
- If the dirty bit is already set, we first append a separator then perform the append.
