Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
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))
)
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)