mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
BlenderBIM Git merge asymmetry heuristic (#3096)
`ifcmerge` is asymmetrical. When both branches have new entities, either local or remote step Ids need to be renumbered to resolve the merge conflict. If the remote branch is 'origin/main' or 'main' we preserve remote Ids, otherwise we preserve local Ids. This should support a workflow where a local 'main' branch is kept pristine, but other local branches are treated as disposable; it should also support a workflow where multiple authors access a shared 'origin'.
This commit is contained in:
@@ -421,13 +421,19 @@ class IfcGit:
|
||||
for branch in lookup[item.hexsha]:
|
||||
if branch.name == props.display_branch:
|
||||
# this is a branch!
|
||||
if re.match("^(origin/)?(HEAD|main|master)$", branch.name):
|
||||
# preserve remote IDs in origin/main or main
|
||||
mergetool = "ifcmerge"
|
||||
else:
|
||||
# rewrite remote IDs
|
||||
mergetool = "ifcmerge-forward"
|
||||
try:
|
||||
# NOTE this is calling the git binary in a subprocess
|
||||
repo.git.merge(branch)
|
||||
except git.exc.GitCommandError:
|
||||
# merge is expected to fail, run ifcmerge
|
||||
try:
|
||||
repo.git.mergetool(tool="ifcmerge")
|
||||
repo.git.mergetool(tool=mergetool)
|
||||
except git.exc.GitCommandError as exc:
|
||||
message = re.sub("( stderr: '|')", "", exc.stderr)
|
||||
# ifcmerge failed, rollback
|
||||
|
||||
Reference in New Issue
Block a user