MCPcopy
hub / github.com/sqlalchemy/alembic / _catch_revision_errors

Method _catch_revision_errors

alembic/script/base.py:204–247  ·  view source on GitHub ↗
(
        self,
        ancestor: Optional[str] = None,
        multiple_heads: Optional[str] = None,
        start: Optional[str] = None,
        end: Optional[str] = None,
        resolution: Optional[str] = None,
    )

Source from the content-addressed store, hash-verified

202
203 @contextmanager
204 def _catch_revision_errors(
205 self,
206 ancestor: Optional[str] = None,
207 multiple_heads: Optional[str] = None,
208 start: Optional[str] = None,
209 end: Optional[str] = None,
210 resolution: Optional[str] = None,
211 ) -> Iterator[None]:
212 try:
213 yield
214 except revision.RangeNotAncestorError as rna:
215 if start is None:
216 start = cast(Any, rna.lower)
217 if end is None:
218 end = cast(Any, rna.upper)
219 if not ancestor:
220 ancestor = (
221 "Requested range %(start)s:%(end)s does not refer to "
222 "ancestor/descendant revisions along the same branch"
223 )
224 ancestor = ancestor % {"start": start, "end": end}
225 raise util.CommandError(ancestor) from rna
226 except revision.MultipleHeads as mh:
227 if not multiple_heads:
228 multiple_heads = (
229 "Multiple head revisions are present for given "
230 "argument '%(head_arg)s'; please "
231 "specify a specific target revision, "
232 "'<branchname>@%(head_arg)s' to "
233 "narrow to a specific head, or 'heads' for all heads"
234 )
235 multiple_heads = multiple_heads % {
236 "head_arg": end or mh.argument,
237 "heads": util.format_as_comma(mh.heads),
238 }
239 raise util.CommandError(multiple_heads) from mh
240 except revision.ResolutionError as re:
241 if resolution is None:
242 resolution = "Can't locate revision identified by '%s'" % (
243 re.argument
244 )
245 raise util.CommandError(resolution) from re
246 except revision.RevisionError as err:
247 raise util.CommandError(err.args[0]) from err
248
249 def walk_revisions(
250 self, base: str = "base", head: str = "heads"

Callers 10

walk_revisionsMethod · 0.95
get_revisionsMethod · 0.95
get_all_currentMethod · 0.95
get_revisionMethod · 0.95
as_revision_numberMethod · 0.95
get_current_headMethod · 0.95
_upgrade_revsMethod · 0.95
_downgrade_revsMethod · 0.95
_stamp_revsMethod · 0.95
generate_revisionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected