示例#1
0
def reposetup(ui, repo):
    # use reposetup, not uisetup to work better with chg and it checks reporc.
    if not repo.local():
        return

    nonsystempaths = set(rcutil.userrcpath() + [repo.vfs.join('hgrc')])
    systemconfigs = ui.configlist('configwarn', 'systemconfigs')

    for configname in systemconfigs:
        if '.' not in configname:
            continue

        section, name = configname.split('.', 1)
        source = ui.configsource(section, name)

        if ':' not in source:
            continue

        path, lineno = source.split(':', 1)
        if path in nonsystempaths and lineno.isdigit():
            ui.warn(_('warning: overriding config %s is unsupported (hint: '
                      'remove line %s from %s to resolve this issue)\n')
                    % (configname, lineno, path))
示例#2
0
def configwizard(ui, repo, statedir=None, **opts):
    """Ensure your Mercurial configuration is up to date."""
    runsteps = set(wizardsteps)

    # Mercurial <1.7 had a bug where monkeypatching ui.__class__
    # during uisetup() doesn't work. So we do our own ui.hasconfig()
    # here. Other uses of ui.hasconfig() are allowed, as they will
    # have a properly monkeypatched ui.__class__.
    if 'steps' in ui._data(False)._data.get('configwizard', {}):
        runsteps = set(ui.configlist('configwizard', 'steps'))

    hgversion = util.versiontuple(n=3)

    # The point release version can be None for e.g. X.Y versions. Normalize
    # to make tuple compares work.
    if hgversion[2] is None:
        hgversion = (hgversion[0], hgversion[1], 0)

    if hgversion < MINIMUM_SUPPORTED_VERSION:
        ui.warn(VERSION_TOO_OLD % (
            hgversion[0],
            hgversion[1],
            MINIMUM_SUPPORTED_VERSION[0],
            MINIMUM_SUPPORTED_VERSION[1],
        ))
        raise error.Abort('upgrade Mercurial then run again')

    uiprompt(ui, INITIAL_MESSAGE, default='<RETURN>')

    with demandimport.deactivated():
        # Mercurial 4.2 moved function from scmutil to rcutil.
        try:
            from mercurial.rcutil import userrcpath
        except ImportError:
            from mercurial.scmutil import userrcpath

    configpaths = [p for p in userrcpath() if os.path.exists(p)]
    path = configpaths[0] if configpaths else userrcpath()[0]
    cw = configobjwrapper(path)

    if 'hgversion' in runsteps:
        if _checkhgversion(ui, hgversion):
            return 1

    if 'username' in runsteps:
        _checkusername(ui, cw)

    if 'tweakdefaults' in runsteps:
        _checktweakdefaults(ui, cw)

    if 'diff' in runsteps:
        _checkdiffsettings(ui, cw)

    if 'color' in runsteps:
        _checkcolor(ui, cw, hgversion)

    if 'pager' in runsteps:
        _checkpager(ui, cw, hgversion)

    if 'curses' in runsteps:
        _checkcurses(ui, cw)

    if 'historyediting' in runsteps:
        _checkhistoryediting(ui, cw, hgversion)

    if 'evolve' in runsteps:
        _checkevolve(ui, cw, hgversion)

    if 'fsmonitor' in runsteps:
        _checkfsmonitor(ui, cw, hgversion)

    if 'blackbox' in runsteps:
        _promptnativeextension(
            ui, cw, 'blackbox',
            'Enable logging of commands to help diagnose bugs '
            'and performance problems')

    if 'security' in runsteps:
        _checksecurity(ui, cw, hgversion)

    if 'firefoxtree' in runsteps:
        _promptvctextension(ui, cw, 'firefoxtree', FIREFOXTREE_INFO)

    if 'clang-format' in runsteps:
        _promptvctextension(ui, cw, 'clang-format', CLANG_FORMAT_INFO)

    if 'js-format' in runsteps:
        _promptvctextension(ui, cw, 'js-format', JS_FORMAT_INFO)

    if 'format-source' in runsteps:
        _checkformatsource(ui, cw)

    if 'wip' in runsteps:
        _checkwip(ui, cw)

    if 'smartannotate' in runsteps:
        _checksmartannotate(ui, cw)

    if 'codereview' in runsteps:
        _checkcodereview(ui, cw)

    if 'pushtotry' in runsteps:
        _promptvctextension(ui, cw, 'push-to-try', PUSHTOTRY_INFO)

    if 'multiplevct' in runsteps:
        _checkmultiplevct(ui, cw)

    if 'configchange' in runsteps:
        _handleconfigchange(ui, cw)

    if 'permissions' in runsteps:
        _checkpermissions(ui, cw)

    return 0