コード例 #1
0
    def getsearchmode(query):
        try:
            ctx = web.repo[query]
        except (error.RepoError, error.LookupError):
            # query is not an exact revision pointer, need to
            # decide if it's a revset expression or keywords
            pass
        else:
            return MODE_REVISION, ctx

        revdef = 'reverse(%s)' % query
        try:
            tree = revset.parse(revdef)
        except ParseError:
            # can't parse to a revset tree
            return MODE_KEYWORD, query

        if revset.depth(tree) <= 2:
            # no revset syntax used
            return MODE_KEYWORD, query

        if any((token, (value or '')[:3]) == ('string', 're:')
               for token, value, pos in revset.tokenize(revdef)):
            return MODE_KEYWORD, query

        funcsused = revset.funcsused(tree)
        if not funcsused.issubset(revset.safesymbols):
            return MODE_KEYWORD, query

        mfunc = revset.match(web.repo.ui, revdef)
        try:
            revs = mfunc(web.repo)
            return MODE_REVSET, revs
            # ParseError: wrongly placed tokens, wrongs arguments, etc
            # RepoLookupError: no such revision, e.g. in 'revision:'
            # Abort: bookmark/tag not exists
            # LookupError: ambiguous identifier, e.g. in '(bc)' on a large repo
        except (ParseError, RepoLookupError, Abort, LookupError):
            return MODE_KEYWORD, query
コード例 #2
0
ファイル: webcommands.py プロジェクト: spraints/for-example
    def getsearchmode(query):
        try:
            ctx = web.repo[query]
        except (error.RepoError, error.LookupError):
            # query is not an exact revision pointer, need to
            # decide if it's a revset expression or keywords
            pass
        else:
            return MODE_REVISION, ctx

        revdef = 'reverse(%s)' % query
        try:
            tree, pos = revset.parse(revdef)
        except ParseError:
            # can't parse to a revset tree
            return MODE_KEYWORD, query

        if revset.depth(tree) <= 2:
            # no revset syntax used
            return MODE_KEYWORD, query

        if util.any((token, (value or '')[:3]) == ('string', 're:')
                    for token, value, pos in revset.tokenize(revdef)):
            return MODE_KEYWORD, query

        funcsused = revset.funcsused(tree)
        if not funcsused.issubset(revset.safesymbols):
            return MODE_KEYWORD, query

        mfunc = revset.match(web.repo.ui, revdef)
        try:
            revs = mfunc(web.repo, list(web.repo))
            return MODE_REVSET, revs
            # ParseError: wrongly placed tokens, wrongs arguments, etc
            # RepoLookupError: no such revision, e.g. in 'revision:'
            # Abort: bookmark/tag not exists
            # LookupError: ambiguous identifier, e.g. in '(bc)' on a large repo
        except (ParseError, RepoLookupError, Abort, LookupError):
            return MODE_KEYWORD, query