Changeset View
Changeset View
Standalone View
Standalone View
swh/model/hypothesis_strategies.py
Show First 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | branches = draw(dictionaries( | ||||
none(), | none(), | ||||
branch_targets(only_objects=only_objects) | branch_targets(only_objects=only_objects) | ||||
), | ), | ||||
min_size=min_size, | min_size=min_size, | ||||
max_size=max_size, | max_size=max_size, | ||||
)) | )) | ||||
if not only_objects: | if not only_objects: | ||||
# Make sure aliases point to actual branches | # Make sure aliases point to actual branches and no cycles exist | ||||
unresolved_aliases = { | unresolved_aliases = { | ||||
target.target | branch.target | ||||
for target in branches.values() | for name, branch in branches.items() | ||||
if (target | if (branch | ||||
and target.target_type == 'alias' | and branch.target_type == TargetType.ALIAS | ||||
and target.target not in branches) | and (branch.target not in branches or | ||||
(branches[branch.target] and | |||||
branches[branch.target].target == name))) | |||||
} | } | ||||
for alias in unresolved_aliases: | for alias in unresolved_aliases: | ||||
branches[alias] = draw(branch_targets(only_objects=True)) | branches[alias] = draw(branch_targets(only_objects=True)) | ||||
while True: | while True: | ||||
try: | try: | ||||
id_ = snapshot_identifier({ | id_ = snapshot_identifier({ | ||||
'branches': { | 'branches': { | ||||
name: branch.to_dict() if branch else None | name: branch.to_dict() if branch else None | ||||
Show All 25 Lines |