How to use the emmett.orm.migrations.exceptions.MultipleHeads function in emmett

To help you get started, we’ve selected a few emmett examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emmett-framework / emmett / emmett / orm / migrations / scripts.py View on Github external
resolution=None):
        try:
            yield
        except RangeNotAncestorError as rna:
            if start is None:
                start = rna.lower
            if end is None:
                end = rna.upper
            if not ancestor:
                ancestor = (
                    "Requested range %(start)s:%(end)s does not refer to "
                    "ancestor/descendant revisions along the same branch"
                )
            ancestor = ancestor % {"start": start, "end": end}
            raise Exception(ancestor)
        except MultipleHeads as mh:
            if not multiple_heads:
                multiple_heads = (
                    "Multiple head revisions are present for given "
                    "argument '%(head_arg)s'; please "
                    "specify a specific target revision, "
                    "'@%(head_arg)s' to "
                    "narrow to a specific head, or 'heads' for all heads")
            multiple_heads = multiple_heads % {
                "head_arg": end or mh.argument,
                "heads": str(mh.heads)
            }
            raise Exception(multiple_heads)
        except ResolutionError as re:
            if resolution is None:
                resolution = "Can't locate revision identified by '%s'" % (
                    re.argument
github emmett-framework / emmett / emmett / orm / migrations / revisions.py View on Github external
def get_current_head(self):
        current_heads = self.heads
        if len(current_heads) > 1:
            raise MultipleHeads(current_heads, "head")
        if current_heads:
            return current_heads[0]
        else:
            return None
github emmett-framework / emmett / emmett / orm / migrations / exceptions.py View on Github external
def __init__(self, heads, argument):
        self.heads = heads
        self.argument = argument
        super(MultipleHeads, self).__init__(
            "Multiple heads are present for given argument '%s'; "
            "%s" % (argument, ", ".join(heads))
        )
github emmett-framework / emmett / emmett / orm / migrations / revisions.py View on Github external
def get_revision(self, rid):
        resolved_id = self._resolve_revision_number(rid)
        if len(resolved_id) > 1:
            raise MultipleHeads(resolved_id, rid)
        elif resolved_id:
            resolved_id = resolved_id[0]
        return self._revision_for_ident(resolved_id)