我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用re.argument()。
def _catch_revision_errors( self, ancestor=None, multiple_heads=None, start=None, end=None, resolution=None): try: yield except revision.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} compat.raise_from_cause(util.CommandError(ancestor)) except revision.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, " "'<branchname>@%(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": util.format_as_comma(mh.heads) } compat.raise_from_cause(util.CommandError(multiple_heads)) except revision.ResolutionError as re: if resolution is None: resolution = "Can't locate revision identified by '%s'" % ( re.argument ) compat.raise_from_cause(util.CommandError(resolution)) except revision.RevisionError as err: compat.raise_from_cause(util.CommandError(err.args[0]))