collaboration.merge module¶
Class |
Description |
---|---|
Helper class that resolves conflicts |
|
Helper class that takes one merge conflict and splits it into multiple conflicts |
|
Structure representing an individual merge conflict |
- class ConflictHandler[source]
Bases:
object
Helper class that resolves conflicts
- abstract handle(conflicts: Dict[str, MergeConflict]) bool [source]
Handle any merge conflicts by calling their success() function with a merged value
- Parameters:
conflicts (Dict[str, MergeConflict]) – Map of conflict id to conflict structure
- Returns:
True if all conflicts were successfully merged
- Return type:
- class ConflictSplitter[source]
Bases:
object
Helper class that takes one merge conflict and splits it into multiple conflicts Eg takes conflicts for View/symbols and splits to one conflict per symbol
- __init__(handle=None)[source]
- abstract can_split(key: str, conflict: MergeConflict) bool [source]
Test if the splitter applies to a given conflict (by key).
- Parameters:
key (str) – Key of the conflicting field
conflict (MergeConflict) – Conflict data
- Returns:
True if this splitter should be used on the conflict
- Return type:
- finished()[source]
Clean up any internal state after the merge operation has finished
- get_name() str [source]
Get a friendly name for the splitter
- Returns:
Name of the splitter
- Return type:
- register()[source]
- reset()[source]
Reset any internal state the splitter may hold during the merge
- abstract split(key: str, conflict: MergeConflict, result: KeyValueStore) Dict[str, MergeConflict] | None [source]
Split a field conflict into any number of alternate conflicts. Note: Returned conflicts will also be checked for splitting, beware infinite loops! If this function raises, it will be treated as returning None
- Parameters:
key (str) – Original conflicting field’s key
conflict (MergeConflict) – Original conflict data
result (KeyValueStore) – Kvs structure containing the result of all splits. You should use the original conflict’s success() function in most cases unless you specifically want to write a new key to this.
- Returns:
A collection of conflicts into which the original conflict was split, or None if this splitter cannot handle the conflict
- Return type:
Dict[str, MergeConflict] | None
- property name
Get a friendly name for the splitter
- Returns:
Name of the splitter
- class MergeConflict[source]
Bases:
object
Structure representing an individual merge conflict
- __init__(handle: LP_BNAnalysisMergeConflict)[source]
FFI constructor
- Parameters:
handle (LP_BNAnalysisMergeConflict) – FFI handle for internal use
- get_path_item(path_key: str) object | None [source]
Get item in the merge conflict’s path for a given key.
- success(value: Dict[str, object] | None) bool [source]
Call this when you’ve resolved the conflict to save the result
- property base: Dict[str, object] | None
Json object for conflicting data in the base snapshot
- Returns:
Python dictionary from parsed json
- property base_file: FileMetadata | None
FileMetadata with contents of file for base snapshot This function is slow! Only use it if you really need it.
- Returns:
FileMetadata object
- property base_snapshot: Snapshot | None
Snapshot which is the parent of the two being merged
- Returns:
Snapshot object
- property data_type: MergeConflictDataType
Type of data in the conflict, Text/Json/Binary
- Returns:
Conflict data type
- property database: Database
Database backing all snapshots in the merge conflict
- Returns:
Database object
- property first: Dict[str, object] | None
Json object for conflicting data in the first snapshot
- Returns:
Python dictionary from parsed json
- property first_file: FileMetadata | None
FileMetadata with contents of file for first snapshot This function is slow! Only use it if you really need it.
- Returns:
FileMetadata object
- property key: str
Lookup key for the merge conflict, ideally a tree path that contains the name of the conflict and all the recursive children leading up to this conflict.
- Returns:
Key name
- property second: Dict[str, object] | None
Json object for conflicting data in the second snapshot
- Returns:
Python dictionary from parsed json
- property second_file: FileMetadata | None
FileMetadata with contents of file for second snapshot This function is slow! Only use it if you really need it.
- Returns:
FileMetadata object
- property type: str
String representing the type name of the data, not the same as data_type. This is like “typeName” or “tag” depending on what object the conflict represents.
- Returns:
Type name
ConflictHandler¶
- class ConflictHandler[source]¶
Bases:
object
Helper class that resolves conflicts
- abstract handle(conflicts: Dict[str, MergeConflict]) bool [source]¶
Handle any merge conflicts by calling their success() function with a merged value
- Parameters:
conflicts (Dict[str, MergeConflict]) – Map of conflict id to conflict structure
- Returns:
True if all conflicts were successfully merged
- Return type:
ConflictSplitter¶
- class ConflictSplitter[source]¶
Bases:
object
Helper class that takes one merge conflict and splits it into multiple conflicts Eg takes conflicts for View/symbols and splits to one conflict per symbol
- abstract can_split(key: str, conflict: MergeConflict) bool [source]¶
Test if the splitter applies to a given conflict (by key).
- Parameters:
key (str) – Key of the conflicting field
conflict (MergeConflict) – Conflict data
- Returns:
True if this splitter should be used on the conflict
- Return type:
- get_name() str [source]¶
Get a friendly name for the splitter
- Returns:
Name of the splitter
- Return type:
- abstract split(key: str, conflict: MergeConflict, result: KeyValueStore) Dict[str, MergeConflict] | None [source]¶
Split a field conflict into any number of alternate conflicts. Note: Returned conflicts will also be checked for splitting, beware infinite loops! If this function raises, it will be treated as returning None
- Parameters:
key (str) – Original conflicting field’s key
conflict (MergeConflict) – Original conflict data
result (KeyValueStore) – Kvs structure containing the result of all splits. You should use the original conflict’s success() function in most cases unless you specifically want to write a new key to this.
- Returns:
A collection of conflicts into which the original conflict was split, or None if this splitter cannot handle the conflict
- Return type:
Dict[str, MergeConflict] | None
- property name¶
Get a friendly name for the splitter
- Returns:
Name of the splitter
MergeConflict¶
- class MergeConflict[source]¶
Bases:
object
Structure representing an individual merge conflict
- __init__(handle: LP_BNAnalysisMergeConflict)[source]¶
FFI constructor
- Parameters:
handle (LP_BNAnalysisMergeConflict) – FFI handle for internal use
- get_path_item(path_key: str) object | None [source]¶
Get item in the merge conflict’s path for a given key.
- success(value: Dict[str, object] | None) bool [source]¶
Call this when you’ve resolved the conflict to save the result
- property base: Dict[str, object] | None¶
Json object for conflicting data in the base snapshot
- Returns:
Python dictionary from parsed json
- property base_file: FileMetadata | None¶
FileMetadata with contents of file for base snapshot This function is slow! Only use it if you really need it.
- Returns:
FileMetadata object
- property base_snapshot: Snapshot | None¶
Snapshot which is the parent of the two being merged
- Returns:
Snapshot object
- property data_type: MergeConflictDataType¶
Type of data in the conflict, Text/Json/Binary
- Returns:
Conflict data type
- property database: Database¶
Database backing all snapshots in the merge conflict
- Returns:
Database object
- property first: Dict[str, object] | None¶
Json object for conflicting data in the first snapshot
- Returns:
Python dictionary from parsed json
- property first_file: FileMetadata | None¶
FileMetadata with contents of file for first snapshot This function is slow! Only use it if you really need it.
- Returns:
FileMetadata object
- property key: str¶
Lookup key for the merge conflict, ideally a tree path that contains the name of the conflict and all the recursive children leading up to this conflict.
- Returns:
Key name
- property second: Dict[str, object] | None¶
Json object for conflicting data in the second snapshot
- Returns:
Python dictionary from parsed json
- property second_file: FileMetadata | None¶
FileMetadata with contents of file for second snapshot This function is slow! Only use it if you really need it.
- Returns:
FileMetadata object