Skip to content

Commit 71f0d4a

Browse files
authored
fix(cli): fix mergetool not working with OOBuckets (#3023)
1 parent fface86 commit 71f0d4a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

renku/infrastructure/git_merger.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
"""Merge strategies."""
1919

2020
import os
21+
import shutil
2122
from json import JSONDecodeError
2223
from pathlib import Path
2324
from tempfile import mkdtemp
2425
from typing import List, NamedTuple, Optional, Union, cast
2526

26-
from BTrees.OOBTree import BTree, TreeSet
27+
from BTrees.OOBTree import BTree, Bucket, TreeSet
2728
from deepdiff import DeepDiff
2829
from persistent import Persistent
2930
from persistent.list import PersistentList
@@ -86,6 +87,7 @@ def merge(self, local: Path, remote: Path, base: Path) -> None:
8687
# NOTE: cleanup worktrees
8788
for entry in self.remote_entries:
8889
client.repository.remove_worktree(entry.path)
90+
shutil.rmtree(entry.path, ignore_errors=True)
8991

9092
if not merged:
9193
raise errors.MetadataMergeError("Couldn't merge metadata: remote object not found in merge branches.")
@@ -128,7 +130,7 @@ def merge_objects(self, local: Persistent, remote: Persistent, base: Optional[Pe
128130
"""Merge two database objects."""
129131
if type(local) != type(remote):
130132
raise errors.MetadataMergeError(f"Cannot merge {local} and {remote}: disparate types.")
131-
if isinstance(local, (BTree, Index)):
133+
if isinstance(local, (BTree, Index, Bucket)):
132134
return self.merge_btrees(local, remote)
133135
elif isinstance(local, TreeSet):
134136
return self.merge_treesets(local, remote)
@@ -141,7 +143,9 @@ def merge_objects(self, local: Persistent, remote: Persistent, base: Optional[Pe
141143
f"Cannot merge {local} and {remote}: type not supported for automated merge."
142144
)
143145

144-
def merge_btrees(self, local: Union[BTree, Index], remote: Union[BTree, Index]) -> Union[BTree, Index]:
146+
def merge_btrees(
147+
self, local: Union[BTree, Index, Bucket], remote: Union[BTree, Index, Bucket]
148+
) -> Union[BTree, Index, Bucket]:
145149
"""Merge two BTrees."""
146150
local_key_ids = {k: getattr(v, "_p_oid", None) for k, v in local.items()}
147151
remote_key_ids = {k: getattr(v, "_p_oid", None) for k, v in remote.items()}

0 commit comments

Comments
 (0)