-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add validation for branch merge #4767
Conversation
CodSpeed Performance ReportMerging #4767 will degrade performances by 24.25%Comparing Summary
Benchmarks breakdown
|
78b794d
to
c319d71
Compare
registry.schema.set_schema_branch(name=obj.name, schema=updated_schema) | ||
obj.update_schema_hash() | ||
await obj.save(db=service.database) | ||
async with lock.registry.global_graph_lock(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just moving this all inside of a global graph lock
and conflict.selected_branch is ConflictSelection.DIFF_BRANCH | ||
and conflict.base_branch_value | ||
and conflict.base_branch_action in (DiffAction.ADDED, DiffAction.UPDATED) | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there is a conflict and the diff version is selected, we need to delete the version on main, which we were not doing before
def get_all_conflicts(self) -> list[EnrichedDiffConflict]: | ||
return [prop.conflict for prop in self.properties if prop.conflict] | ||
def get_all_conflicts(self) -> dict[str, EnrichedDiffConflict]: | ||
return {prop.path_identifier: prop.conflict for prop in self.properties if prop.conflict} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updates to return a map of path identifier to EnrichedDiffConflict
@@ -390,7 +390,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: | |||
WHERE type(r_prop) = prop_type | |||
AND r_prop.status = prop_rel_status | |||
AND r_prop.from <= $at | |||
AND (r_prop.to >= $at OR r_prop.to IS NULL) | |||
AND (r_prop.to > $at OR r_prop.to IS NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this off-by-one time error was causing a bug where the merge would delete an edge that it had just updated because the to
time was set to $at
@@ -226,50 +229,32 @@ async def validate_graph(self) -> list[DataConflict]: | |||
async def merge( | |||
self, | |||
at: Optional[Union[str, Timestamp]] = None, | |||
conflict_resolution: Optional[dict[str, bool]] = None, | |||
conflict_resolution: Optional[dict[str, bool]] = None, # pylint: disable=unused-argument |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will completely remove conflict_resolution
in my next PR or 2
@@ -96,3 +87,161 @@ async def test_diff_and_merge_schema_with_default_values( | |||
assert new_bool_attr.default_value is False | |||
new_str_attr = car_schema_main.get_attribute(name="nickname") | |||
assert new_str_attr.default_value == "car" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few new tests to make sure that the merge is correctly handling resolved conflicts
fixes #4595
IFC-767
adds validation to the
BranchMerge
mutation to prevent merging a branch with constraint violations or diff conflicts