Skip to content

Commit 6418529

Browse files
committed
Old collab: Add api for merge snapshots
1 parent 4502768 commit 6418529

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

python/collaboration/merge.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,3 +396,20 @@ def split(self, key: str, conflict: MergeConflict, result: KeyValueStore) -> Opt
396396
this splitter cannot handle the conflict
397397
"""
398398
raise NotImplementedError("Not implemented")
399+
400+
401+
def merge_snapshots(first: Snapshot, second: Snapshot, conflict_handler: 'util.ConflictHandlerType', progress: Optional['util.ProgressFuncType'] = None):
402+
"""
403+
Merge two snapshots in a database down to a single leaf snapshot.
404+
405+
:param first: First snapshot
406+
:param second: Second snapshot
407+
:param conflict_handler: Function to call for progress updates
408+
:param progress: Function to call to resolve snapshot conflicts
409+
:raises RuntimeError: If there was an error (or the operation was cancelled)
410+
"""
411+
if progress is None:
412+
progress = util.nop
413+
414+
if not core.BNCollaborationMergeSnapshots(first.handle, second.handle, util.wrap_conflict_handler(conflict_handler), None, util.wrap_progress(progress), None):
415+
raise RuntimeError(util._last_error())

0 commit comments

Comments
 (0)