예제 #1
0
파일: chgserver.py 프로젝트: motlin/cyg
def _loadnewui(srcui, args):
    newui = srcui.__class__()
    for a in ['fin', 'fout', 'ferr', 'environ']:
        setattr(newui, a, getattr(srcui, a))
    if util.safehasattr(srcui, '_csystem'):
        newui._csystem = srcui._csystem

    # internal config: extensions.chgserver
    newui.setconfig('extensions', 'chgserver',
                    srcui.config('extensions', 'chgserver'), '--config')

    # command line args
    args = args[:]
    dispatch._parseconfig(newui, dispatch._earlygetopt(['--config'], args))

    # stolen from tortoisehg.util.copydynamicconfig()
    for section, name, value in srcui.walkconfig():
        source = srcui.configsource(section, name)
        if ':' in source or source == '--config':
            # path:line or command line
            continue
        if source == 'none':
            # ui.configsource returns 'none' by default
            source = ''
        newui.setconfig(section, name, value, source)

    # load wd and repo config, copied from dispatch.py
    cwds = dispatch._earlygetopt(['--cwd'], args)
    cwd = cwds and os.path.realpath(cwds[-1]) or None
    rpath = dispatch._earlygetopt(["-R", "--repository", "--repo"], args)
    path, newlui = dispatch._getlocal(newui, rpath, wd=cwd)

    return (newui, newlui)
예제 #2
0
파일: chgserver.py 프로젝트: anydeploy/hg
def _loadnewui(srcui, args):
    newui = srcui.__class__()
    for a in ['fin', 'fout', 'ferr', 'environ']:
        setattr(newui, a, getattr(srcui, a))
    if util.safehasattr(srcui, '_csystem'):
        newui._csystem = srcui._csystem

    # internal config: extensions.chgserver
    newui.setconfig('extensions', 'chgserver',
                    srcui.config('extensions', 'chgserver'), '--config')

    # command line args
    args = args[:]
    dispatch._parseconfig(newui, dispatch._earlygetopt(['--config'], args))

    # stolen from tortoisehg.util.copydynamicconfig()
    for section, name, value in srcui.walkconfig():
        source = srcui.configsource(section, name)
        if ':' in source or source == '--config':
            # path:line or command line
            continue
        if source == 'none':
            # ui.configsource returns 'none' by default
            source = ''
        newui.setconfig(section, name, value, source)

    # load wd and repo config, copied from dispatch.py
    cwds = dispatch._earlygetopt(['--cwd'], args)
    cwd = cwds and os.path.realpath(cwds[-1]) or None
    rpath = dispatch._earlygetopt(["-R", "--repository", "--repo"], args)
    path, newlui = dispatch._getlocal(newui, rpath, wd=cwd)

    return (newui, newlui)
예제 #3
0
def uisetup(ui):
    # uisetup is called when the extension is first loaded and receives a ui object:
    # https://www.mercurial-scm.org/wiki/WritingExtensions#Setup_Callbacks
    # We must force the reading of the projrc in uisetup or any other modules with "def uisetup(ui):" won't have access to projrc until the extsetup callback fires. e.g. ui.config("..
    args = sys.argv[1:]
    rpath = []
    if hasattr(dispatch, "_earlygetopt"):
        rpath = dispatch._earlygetopt(["-R", "--repository", "--repo"], args)
    readprojrc(ui, rpath)
예제 #4
0
 def disp_parse(orig, ui, args):
     if type(ui) == _ui.ui:
         args = win32helper.getargs()[:]
         dispatch._earlygetopt(['--config'], args)
         dispatch._earlygetopt(['--cwd'], args)
         dispatch._earlygetopt(["-R", "--repository", "--repo"], args)
     return orig(ui, args)
예제 #5
0
파일: fixutf8.py 프로젝트: sillsdev/chack
 def disp_parse(orig, ui, args):
     if type(ui) == _ui.ui:
         args = win32helper.getargs()[:]
         dispatch._earlygetopt(['--config'], args)
         dispatch._earlygetopt(['--cwd'], args)
         dispatch._earlygetopt(["-R", "--repository", "--repo"], args)
     return orig(ui, args)
예제 #6
0
파일: pager.py 프로젝트: nermina86/docker
def uisetup(ui):
    if '--debugger' in sys.argv or not ui.formatted():
        return

    # chg has its own pager implementation
    argv = sys.argv[:]
    if 'chgunix' in dispatch._earlygetopt(['--cmdserver'], argv):
        return

    def pagecmd(orig, ui, options, cmd, cmdfunc):
        p = ui.config("pager", "pager", os.environ.get("PAGER"))
        usepager = False
        always = util.parsebool(options['pager'])
        auto = options['pager'] == 'auto'

        if not p:
            pass
        elif always:
            usepager = True
        elif not auto:
            usepager = False
        else:
            attend = ui.configlist('pager', 'attend', attended)
            ignore = ui.configlist('pager', 'ignore')
            cmds, _ = cmdutil.findcmd(cmd, commands.table)

            for cmd in cmds:
                var = 'attend-%s' % cmd
                if ui.config('pager', var):
                    usepager = ui.configbool('pager', var)
                    break
                if (cmd in attend or (cmd not in ignore and not attend)):
                    usepager = True
                    break

        setattr(ui, 'pageractive', usepager)

        if usepager:
            ui.setconfig('ui', 'formatted', ui.formatted(), 'pager')
            ui.setconfig('ui', 'interactive', False, 'pager')
            if util.safehasattr(signal, "SIGPIPE"):
                signal.signal(signal.SIGPIPE, signal.SIG_DFL)
            _runpager(ui, p)
        return orig(ui, options, cmd, cmdfunc)

    # Wrap dispatch._runcommand after color is loaded so color can see
    # ui.pageractive. Otherwise, if we loaded first, color's wrapped
    # dispatch._runcommand would run without having access to ui.pageractive.
    def afterloaded(loaded):
        extensions.wrapfunction(dispatch, '_runcommand', pagecmd)

    extensions.afterloaded('color', afterloaded)
예제 #7
0
파일: pager.py 프로젝트: motlin/cyg
def uisetup(ui):
    if '--debugger' in sys.argv or not ui.formatted():
        return

    # chg has its own pager implementation
    argv = sys.argv[:]
    if 'chgunix' in dispatch._earlygetopt(['--cmdserver'], argv):
        return

    def pagecmd(orig, ui, options, cmd, cmdfunc):
        p = ui.config("pager", "pager", os.environ.get("PAGER"))
        usepager = False
        always = util.parsebool(options['pager'])
        auto = options['pager'] == 'auto'

        if not p:
            pass
        elif always:
            usepager = True
        elif not auto:
            usepager = False
        else:
            attend = ui.configlist('pager', 'attend', attended)
            ignore = ui.configlist('pager', 'ignore')
            cmds, _ = cmdutil.findcmd(cmd, commands.table)

            for cmd in cmds:
                var = 'attend-%s' % cmd
                if ui.config('pager', var):
                    usepager = ui.configbool('pager', var)
                    break
                if (cmd in attend or
                     (cmd not in ignore and not attend)):
                    usepager = True
                    break

        setattr(ui, 'pageractive', usepager)

        if usepager:
            ui.setconfig('ui', 'formatted', ui.formatted(), 'pager')
            ui.setconfig('ui', 'interactive', False, 'pager')
            if util.safehasattr(signal, "SIGPIPE"):
                signal.signal(signal.SIGPIPE, signal.SIG_DFL)
            _runpager(ui, p)
        return orig(ui, options, cmd, cmdfunc)

    # Wrap dispatch._runcommand after color is loaded so color can see
    # ui.pageractive. Otherwise, if we loaded first, color's wrapped
    # dispatch._runcommand would run without having access to ui.pageractive.
    def afterloaded(loaded):
        extensions.wrapfunction(dispatch, '_runcommand', pagecmd)
    extensions.afterloaded('color', afterloaded)
예제 #8
0
def parseconfigopts(ui, args):
    """Pop the --config options from the command line and apply them

    >>> u = uimod.ui()
    >>> args = ['log', '--config', 'extensions.mq=!']
    >>> parseconfigopts(u, args)
    [('extensions', 'mq', '!')]
    >>> args
    ['log']
    >>> u.config('extensions', 'mq')
    '!'
    """
    config = dispatchmod._earlygetopt(['--config'], args)
    return dispatchmod._parseconfig(ui, config)
예제 #9
0
def parseconfigopts(ui, args):
    """Pop the --config options from the command line and apply them

    >>> u = ui.ui()
    >>> args = ['log', '--config', 'extensions.mq=!']
    >>> parseconfigopts(u, args)
    [('extensions', 'mq', '!')]
    >>> args
    ['log']
    >>> u.config('extensions', 'mq')
    '!'
    """
    config = dispatchmod._earlygetopt(['--config'], args)
    return dispatchmod._parseconfig(ui, config)