Skip to content

Commit 27d9cae

Browse files
committed
Bonsai, bump ifcmerge.exe to working version with deps
Don't leave a broken repo if ifcmerge is misinstalled. Fix bug where only local branches could be merged. Fix gitch where merge commits were not considered relevant.
1 parent a751c1c commit 27d9cae

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

src/bonsai/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ PYNUMBER:=3$(PYMINOR)
6464
PYPI_VERSION:=3.$(PYMINOR)
6565
endif # def PYVERSION
6666

67-
IFCMERGE_VERSION:=2026-04-02
67+
IFCMERGE_VERSION:=2026-04-07
6868

6969
ifdef PLATFORM
7070
SUPPORTED_PLATFORMS := linux macos macosm1 win

src/bonsai/bonsai/core/ifcgit.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,11 @@ def merge_branch(ifcgit: type[tool.IfcGit], ifc: type[tool.Ifc], operator: bpy.t
151151
conflicts = ifcgit.git_mergetool(mergetool, path_ifc)
152152
if conflicts is not None:
153153
ifcgit.git_merge_abort()
154-
ifcgit.store_merge_conflicts(conflicts)
155-
operator.report({"WARNING"}, "Merge failed — see the conflict report in the panel below")
154+
if conflicts:
155+
ifcgit.store_merge_conflicts(conflicts)
156+
operator.report({"WARNING"}, "Merge failed — see the conflict report in the panel below")
157+
else:
158+
operator.report({"ERROR"}, "Merge tool failed — check that ifcmerge is installed correctly")
156159
return False
157160
ifcgit.commit_merge(path_ifc)
158161

src/bonsai/bonsai/tool/ifcgit.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,19 +217,25 @@ def get_commits_list(cls, path_ifc: str, lookup: dict[str, Any]) -> None:
217217
rev=[props.display_branch],
218218
)
219219
)
220-
commits_relevant = list(
220+
commits_relevant = set(
221221
git.objects.commit.Commit.iter_items(
222222
repo=repo,
223223
rev=[props.display_branch],
224224
paths=[path_ifc],
225225
)
226226
)
227227

228+
def is_relevant(commit):
229+
if commit in commits_relevant:
230+
return True
231+
# Merge commits are relevant too
232+
return len(commit.parents) > 1 and any(p in commits_relevant for p in commit.parents)
233+
228234
for commit in commits:
229235

230236
if props.ifcgit_filter == "tagged" and commit.hexsha not in lookup:
231237
continue
232-
elif props.ifcgit_filter == "relevant" and commit not in commits_relevant:
238+
elif props.ifcgit_filter == "relevant" and not is_relevant(commit):
233239
continue
234240

235241
props.ifcgit_commits.add()
@@ -239,7 +245,7 @@ def get_commits_list(cls, path_ifc: str, lookup: dict[str, Any]) -> None:
239245
list_item.author_name = commit.author.name
240246
list_item.author_email = commit.author.email
241247
list_item.committed_date = int(commit.committed_date)
242-
if commit in commits_relevant:
248+
if is_relevant(commit):
243249
list_item.relevant = True
244250
if commit.hexsha in lookup:
245251
for tag in lookup[commit.hexsha]:
@@ -589,7 +595,7 @@ def git_merge(cls, branch_name: str) -> Union[str, None]:
589595
"""Attempt a git merge. Returns None on clean merge, 'conflict' on expected
590596
GitCommandError, or 'error' on an unknown GitError."""
591597
repo = IfcGitRepo.repo
592-
branch = repo.branches[branch_name]
598+
branch = repo.refs[branch_name]
593599
try:
594600
repo.git.merge(branch)
595601
return None
@@ -603,7 +609,7 @@ def git_merge_no_commit(cls, branch_name: str) -> Union[str, None]:
603609
"""Attempt a git merge without committing (always leaves a merge state to abort).
604610
Returns None on clean merge, 'conflict' on conflict, or 'error' on unknown failure."""
605611
repo = IfcGitRepo.repo
606-
branch = repo.branches[branch_name]
612+
branch = repo.refs[branch_name]
607613
try:
608614
repo.git.merge(branch, no_commit=True, no_ff=True)
609615
return None
@@ -619,8 +625,8 @@ def git_mergetool(cls, mergetool: str, path_ifc: str) -> Union[list, None]:
619625
report_path = path_ifc + ".ifcmerge"
620626
try:
621627
repo.git.mergetool(tool=mergetool)
622-
except git.exc.GitCommandError:
623-
pass
628+
except git.exc.GitCommandError as e:
629+
print(f"ifcgit: mergetool failed: {e}")
624630

625631
conflicts = None
626632
if os.path.exists(report_path):
@@ -636,6 +642,10 @@ def git_mergetool(cls, mergetool: str, path_ifc: str) -> Union[list, None]:
636642
os.remove(report_path)
637643
except OSError:
638644
pass
645+
646+
if conflicts is None and repo.index.unmerged_blobs():
647+
conflicts = []
648+
639649
return conflicts
640650

641651
@classmethod

0 commit comments

Comments
 (0)