Пример #1
0
def uisetup(ui):
    for cmd, path in ui.configitems('extdiff'):
        path = util.expandpath(path)
        if cmd.startswith('cmd.'):
            cmd = cmd[4:]
            if not path:
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
            diffopts = ui.config('extdiff', 'opts.' + cmd, '')
            cmdline = util.shellquote(path)
            if diffopts:
                cmdline += ' ' + diffopts
        elif cmd.startswith('opts.'):
            continue
        else:
            if path:
                # case "cmd = path opts"
                cmdline = path
                diffopts = len(pycompat.shlexsplit(cmdline)) > 1
            else:
                # case "cmd ="
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
                cmdline = util.shellquote(path)
                diffopts = False
        # look for diff arguments in [diff-tools] then [merge-tools]
        if not diffopts:
            args = ui.config('diff-tools', cmd+'.diffargs') or \
                   ui.config('merge-tools', cmd+'.diffargs')
            if args:
                cmdline += ' ' + args
        command(cmd, extdiffopts[:], _('hg %s [OPTION]... [FILE]...') % cmd,
                inferrepo=True)(savedcmd(path, cmdline))
Пример #2
0
def uisetup(ui):
    for cmd, path in ui.configitems('extdiff'):
        path = util.expandpath(path)
        if cmd.startswith('cmd.'):
            cmd = cmd[4:]
            if not path:
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
            diffopts = ui.config('extdiff', 'opts.' + cmd, '')
            cmdline = util.shellquote(path)
            if diffopts:
                cmdline += ' ' + diffopts
        elif cmd.startswith('opts.'):
            continue
        else:
            if path:
                # case "cmd = path opts"
                cmdline = path
                diffopts = len(shlex.split(cmdline)) > 1
            else:
                # case "cmd ="
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
                cmdline = util.shellquote(path)
                diffopts = False
        # look for diff arguments in [diff-tools] then [merge-tools]
        if not diffopts:
            args = ui.config('diff-tools', cmd+'.diffargs') or \
                   ui.config('merge-tools', cmd+'.diffargs')
            if args:
                cmdline += ' ' + args
        command(cmd, extdiffopts[:], _('hg %s [OPTION]... [FILE]...') % cmd,
                inferrepo=True)(savedcmd(path, cmdline))
Пример #3
0
def uisetup(ui):
    for cmd, path in ui.configitems('extdiff'):
        path = util.expandpath(path)
        if cmd.startswith('cmd.'):
            cmd = cmd[4:]
            if not path:
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
            diffopts = ui.config('extdiff', 'opts.' + cmd, '')
            cmdline = util.shellquote(path)
            if diffopts:
                cmdline += ' ' + diffopts
        elif cmd.startswith('opts.'):
            continue
        else:
            if path:
                # case "cmd = path opts"
                cmdline = path
                diffopts = len(shlex.split(cmdline)) > 1
            else:
                # case "cmd ="
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
                cmdline = util.shellquote(path)
                diffopts = False
        # look for diff arguments in [diff-tools] then [merge-tools]
        if not diffopts:
            args = ui.config('diff-tools', cmd+'.diffargs') or \
                   ui.config('merge-tools', cmd+'.diffargs')
            if args:
                cmdline += ' ' + args
        def save(cmdline):
            '''use closure to save diff command to use'''
            def mydiff(ui, repo, *pats, **opts):
                options = ' '.join(map(util.shellquote, opts['option']))
                if options:
                    options = ' ' + options
                return dodiff(ui, repo, cmdline + options, pats, opts)
            # We can't pass non-ASCII through docstrings (and path is
            # in an unknown encoding anyway)
            docpath = path.encode("string-escape")
            mydiff.__doc__ = '''\
use %(path)s to diff repository (or selected files)

    Show differences between revisions for the specified files, using
    the %(path)s program.

    When two revision arguments are given, then changes are shown
    between those revisions. If only one revision is specified then
    that revision is compared to the working directory, and, when no
    revisions are specified, the working directory files are compared
    to its parent.\
''' % {'path': util.uirepr(docpath)}
            return mydiff
        command(cmd, extdiffopts[:], _('hg %s [OPTION]... [FILE]...') % cmd,
                inferrepo=True)(save(cmdline))
Пример #4
0
def _gettooldetails(ui, cmd, path):
    """
    returns following things for a
    ```
    [extdiff]
    <cmd> = <path>
    ```
    entry:

    cmd: command/tool name
    path: path to the tool
    cmdline: the command which should be run
    isgui: whether the tool uses GUI or not

    Reads all external tools related configs, whether it be extdiff section,
    diff-tools or merge-tools section, or its specified in an old format or
    the latest format.
    """
    path = util.expandpath(path)
    if cmd.startswith(b'cmd.'):
        cmd = cmd[4:]
        if not path:
            path = procutil.findexe(cmd)
            if path is None:
                path = filemerge.findexternaltool(ui, cmd) or cmd
        diffopts = ui.config(b'extdiff', b'opts.' + cmd)
        cmdline = procutil.shellquote(path)
        if diffopts:
            cmdline += b' ' + diffopts
        isgui = ui.configbool(b'extdiff', b'gui.' + cmd)
    else:
        if path:
            # case "cmd = path opts"
            cmdline = path
            diffopts = len(pycompat.shlexsplit(cmdline)) > 1
        else:
            # case "cmd ="
            path = procutil.findexe(cmd)
            if path is None:
                path = filemerge.findexternaltool(ui, cmd) or cmd
            cmdline = procutil.shellquote(path)
            diffopts = False
        isgui = ui.configbool(b'extdiff', b'gui.' + cmd)
    # look for diff arguments in [diff-tools] then [merge-tools]
    if not diffopts:
        key = cmd + b'.diffargs'
        for section in (b'diff-tools', b'merge-tools'):
            args = ui.config(section, key)
            if args:
                cmdline += b' ' + args
                if isgui is None:
                    isgui = ui.configbool(section, cmd + b'.gui') or False
                break
    return cmd, path, cmdline, isgui
Пример #5
0
def uisetup(ui):
    for cmd, path in ui.configitems(b'extdiff'):
        path = util.expandpath(path)
        if cmd.startswith(b'cmd.'):
            cmd = cmd[4:]
            if not path:
                path = procutil.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
            diffopts = ui.config(b'extdiff', b'opts.' + cmd)
            cmdline = procutil.shellquote(path)
            if diffopts:
                cmdline += b' ' + diffopts
            isgui = ui.configbool(b'extdiff', b'gui.' + cmd)
        elif cmd.startswith(b'opts.') or cmd.startswith(b'gui.'):
            continue
        else:
            if path:
                # case "cmd = path opts"
                cmdline = path
                diffopts = len(pycompat.shlexsplit(cmdline)) > 1
            else:
                # case "cmd ="
                path = procutil.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
                cmdline = procutil.shellquote(path)
                diffopts = False
            isgui = ui.configbool(b'extdiff', b'gui.' + cmd)
        # look for diff arguments in [diff-tools] then [merge-tools]
        if not diffopts:
            key = cmd + b'.diffargs'
            for section in (b'diff-tools', b'merge-tools'):
                args = ui.config(section, key)
                if args:
                    cmdline += b' ' + args
                    if isgui is None:
                        isgui = ui.configbool(section, cmd + b'.gui') or False
                    break
        command(
            cmd,
            extdiffopts[:],
            _(b'hg %s [OPTION]... [FILE]...') % cmd,
            helpcategory=command.CATEGORY_FILE_CONTENTS,
            inferrepo=True,
        )(savedcmd(path, cmdline, isgui))
Пример #6
0
def uisetup(ui):
    for cmd, path in ui.configitems('extdiff'):
        if cmd.startswith('cmd.'):
            cmd = cmd[4:]
            if not path:
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
            diffopts = ui.config('extdiff', 'opts.' + cmd, '')
            cmdline = util.shellquote(path)
            if diffopts:
                cmdline += ' ' + diffopts
        elif cmd.startswith('opts.'):
            continue
        else:
            if path:
                # case "cmd = path opts"
                cmdline = path
                diffopts = len(shlex.split(cmdline)) > 1
            else:
                # case "cmd ="
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
                cmdline = util.shellquote(path)
                diffopts = False
        # look for diff arguments in [diff-tools] then [merge-tools]
        if not diffopts:
            args = ui.config('diff-tools', cmd+'.diffargs') or \
                   ui.config('merge-tools', cmd+'.diffargs')
            if args:
                cmdline += ' ' + args

        def save(cmdline):
            '''use closure to save diff command to use'''
            def mydiff(ui, repo, *pats, **opts):
                options = ' '.join(map(util.shellquote, opts['option']))
                if options:
                    options = ' ' + options
                return dodiff(ui, repo, cmdline + options, pats, opts)

            doc = _('''\
use %(path)s to diff repository (or selected files)

    Show differences between revisions for the specified files, using
    the %(path)s program.

    When two revision arguments are given, then changes are shown
    between those revisions. If only one revision is specified then
    that revision is compared to the working directory, and, when no
    revisions are specified, the working directory files are compared
    to its parent.\
''') % {
                'path': util.uirepr(path)
            }

            # We must translate the docstring right away since it is
            # used as a format string. The string will unfortunately
            # be translated again in commands.helpcmd and this will
            # fail when the docstring contains non-ASCII characters.
            # Decoding the string to a Unicode string here (using the
            # right encoding) prevents that.
            mydiff.__doc__ = doc.decode(encoding.encoding)
            return mydiff

        cmdtable[cmd] = (save(cmdline), cmdtable['extdiff'][1][1:],
                         _('hg %s [OPTION]... [FILE]...') % cmd)
Пример #7
0
def uisetup(ui):
    for cmd, path in ui.configitems('extdiff'):
        path = util.expandpath(path)
        if cmd.startswith('cmd.'):
            cmd = cmd[4:]
            if not path:
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
            diffopts = ui.config('extdiff', 'opts.' + cmd, '')
            cmdline = util.shellquote(path)
            if diffopts:
                cmdline += ' ' + diffopts
        elif cmd.startswith('opts.'):
            continue
        else:
            if path:
                # case "cmd = path opts"
                cmdline = path
                diffopts = len(shlex.split(cmdline)) > 1
            else:
                # case "cmd ="
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
                cmdline = util.shellquote(path)
                diffopts = False
        # look for diff arguments in [diff-tools] then [merge-tools]
        if not diffopts:
            args = ui.config('diff-tools', cmd+'.diffargs') or \
                   ui.config('merge-tools', cmd+'.diffargs')
            if args:
                cmdline += ' ' + args
        def save(cmdline):
            '''use closure to save diff command to use'''
            def mydiff(ui, repo, *pats, **opts):
                options = ' '.join(map(util.shellquote, opts['option']))
                if options:
                    options = ' ' + options
                return dodiff(ui, repo, cmdline + options, pats, opts)
            doc = _('''\
use %(path)s to diff repository (or selected files)

    Show differences between revisions for the specified files, using
    the %(path)s program.

    When two revision arguments are given, then changes are shown
    between those revisions. If only one revision is specified then
    that revision is compared to the working directory, and, when no
    revisions are specified, the working directory files are compared
    to its parent.\
''') % {'path': util.uirepr(path)}

            # We must translate the docstring right away since it is
            # used as a format string. The string will unfortunately
            # be translated again in commands.helpcmd and this will
            # fail when the docstring contains non-ASCII characters.
            # Decoding the string to a Unicode string here (using the
            # right encoding) prevents that.
            mydiff.__doc__ = doc.decode(encoding.encoding)
            return mydiff
        command(cmd, extdiffopts[:], _('hg %s [OPTION]... [FILE]...') % cmd,
                inferrepo=True)(save(cmdline))
Пример #8
0
def uisetup(ui):
    for cmd, path in ui.configitems("extdiff"):
        if cmd.startswith("cmd."):
            cmd = cmd[4:]
            if not path:
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
            diffopts = ui.config("extdiff", "opts." + cmd, "")
            cmdline = util.shellquote(path)
            if diffopts:
                cmdline += " " + diffopts
        elif cmd.startswith("opts."):
            continue
        else:
            if path:
                # case "cmd = path opts"
                cmdline = path
                diffopts = len(shlex.split(cmdline)) > 1
            else:
                # case "cmd ="
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
                cmdline = util.shellquote(path)
                diffopts = False
        # look for diff arguments in [diff-tools] then [merge-tools]
        if not diffopts:
            args = ui.config("diff-tools", cmd + ".diffargs") or ui.config("merge-tools", cmd + ".diffargs")
            if args:
                cmdline += " " + args

        def save(cmdline):
            """use closure to save diff command to use"""

            def mydiff(ui, repo, *pats, **opts):
                options = " ".join(map(util.shellquote, opts["option"]))
                if options:
                    options = " " + options
                return dodiff(ui, repo, cmdline + options, pats, opts)

            doc = (
                _(
                    """\
use %(path)s to diff repository (or selected files)

    Show differences between revisions for the specified files, using
    the %(path)s program.

    When two revision arguments are given, then changes are shown
    between those revisions. If only one revision is specified then
    that revision is compared to the working directory, and, when no
    revisions are specified, the working directory files are compared
    to its parent.\
"""
                )
                % {"path": util.uirepr(path)}
            )

            # We must translate the docstring right away since it is
            # used as a format string. The string will unfortunately
            # be translated again in commands.helpcmd and this will
            # fail when the docstring contains non-ASCII characters.
            # Decoding the string to a Unicode string here (using the
            # right encoding) prevents that.
            mydiff.__doc__ = doc.decode(encoding.encoding)
            return mydiff

        cmdtable[cmd] = (save(cmdline), cmdtable["extdiff"][1][1:], _("hg %s [OPTION]... [FILE]...") % cmd)