mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +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]:
|
for branch in lookup[item.hexsha]:
|
||||||
if branch.name == props.display_branch:
|
if branch.name == props.display_branch:
|
||||||
# this is a 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:
|
try:
|
||||||
# NOTE this is calling the git binary in a subprocess
|
# NOTE this is calling the git binary in a subprocess
|
||||||
repo.git.merge(branch)
|
repo.git.merge(branch)
|
||||||
except git.exc.GitCommandError:
|
except git.exc.GitCommandError:
|
||||||
# merge is expected to fail, run ifcmerge
|
# merge is expected to fail, run ifcmerge
|
||||||
try:
|
try:
|
||||||
repo.git.mergetool(tool="ifcmerge")
|
repo.git.mergetool(tool=mergetool)
|
||||||
except git.exc.GitCommandError as exc:
|
except git.exc.GitCommandError as exc:
|
||||||
message = re.sub("( stderr: '|')", "", exc.stderr)
|
message = re.sub("( stderr: '|')", "", exc.stderr)
|
||||||
# ifcmerge failed, rollback
|
# ifcmerge failed, rollback
|
||||||
|
|||||||
Reference in New Issue
Block a user