DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (561f2b6ba128)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# This file is executed when extensions from this repository load.
# It's goal is to set up sys.path so all libraries are present.

# We do everything in a function so symbols don't leak.
def HGEXT_BOOTSTRAP():
    import os
    import sys

    # __file__ comes from the invoking script (usually). It shouldn't
    # matter.
    here = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
    root = None
    while True:
        if not here:
            break

        possible = os.path.join(here, 'run-tests')
        if os.path.exists(possible):
            root = here
            break

        newhere = os.path.dirname(here)
        if newhere == here:
            break
        here = newhere

    if not here or not root:
        raise Exception('Could not find repository root.')

    paths = set(sys.path)

    lib_paths = [
        'pylib/configobj',
        'pylib/Bugsy',
        'pylib/flake8',
        'pylib/mccabe',
        'pylib/mozautomation',
        'pylib/mozhg',
        'pylib/pycodestyle',
        'pylib/pyflakes',
        'third_party/python/certifi',
        'third_party/python/chardet',
        'third_party/python/idna',
        'third_party/python/requests',
        'third_party/python/six',
        'third_party/python/urllib3',
    ]
    for p in lib_paths:
        full = os.path.normpath(os.path.join(root, p))
        if full not in paths:
            sys.path.insert(0, full)

if not globals().get('HGEXT_BOOTSTRAPPED', False):
    HGEXT_BOOTSTRAP()