def finalise(self):
assert(self._is_solved())<EOL>g = self._get_minimal_graph()<EOL>scopes = dict((x.package_name, x) for x in self.scopes<EOL>if not x.package_request.conflict)<EOL>fam_cycle = find_cycle(g)<EOL>if fam_cycle:<EOL><INDENT>cycle = []<EOL>for fam in fam_cycle:<EOL><INDENT>scope = scopes[fam]<EOL>variant = scope._get_solved_variant()<EOL>stmt = VersionedObject.construct(fam, variant.version)<EOL>cycle.append(stmt)<EOL><DEDENT>phase = copy.copy(self)<EOL>phase.scopes = list(scopes.values())<EOL>phase.failure_reason = Cycle(cycle)<EOL>phase.status = SolverStatus.cyclic<EOL>return phase<EOL><DEDENT>fams = [x.name for x in self.solver.request_list]<EOL>ordered_fams = _get_dependency_order(g, fams)<EOL>scopes_ = []<EOL>for fam in ordered_fams:<EOL><INDENT>scope = scopes[fam]<EOL>if not scope.package_request.conflict:<EOL><INDENT>scopes_.append(scope)<EOL><DEDENT><DEDENT>phase = copy.copy(self)<EOL>phase.scopes = scopes_<EOL>return phase<EOL>
Remove conflict requests, detect cyclic dependencies, and reorder
        packages wrt dependency and then request order.

        Returns:
            A new copy of the phase with conflict requests removed and packages
            correctly ordered; or, if cyclic dependencies were detected, a new
            phase marked as cyclic.