Example #1
0
    def __init__(self, ui, repotype, path, revs=None):
        super(gnuarch_source, self).__init__(ui, repotype, path, revs=revs)

        if not os.path.exists(os.path.join(path, b'{arch}')):
            raise common.NoRepo(
                _(b"%s does not look like a GNU Arch repository") % path)

        # Could use checktool, but we want to check for baz or tla.
        self.execmd = None
        if procutil.findexe(b'baz'):
            self.execmd = b'baz'
        else:
            if procutil.findexe(b'tla'):
                self.execmd = b'tla'
            else:
                raise error.Abort(_(b'cannot find a GNU Arch tool'))

        common.commandline.__init__(self, ui, self.execmd)

        self.path = os.path.realpath(path)
        self.tmppath = None

        self.treeversion = None
        self.lastrev = None
        self.changes = {}
        self.parents = {}
        self.tags = {}
        self.encoding = encoding.encoding
        self.archives = []
Example #2
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
Example #3
0
def checktool(exe, name=None, abort=True):
    name = name or exe
    if not procutil.findexe(exe):
        if abort:
            exc = error.Abort
        else:
            exc = MissingTool
        raise exc(_('cannot find required "%s" tool') % name)
Example #4
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))
Example #5
0
def checktool(exe, name=None, abort=True, debname=None):
    name = name or exe
    if not procutil.findexe(exe):
        if abort:
            exc = error.Abort
        else:
            exc = MissingTool
        raise exc(
            _('cannot find required "%s" tool') % name +
            (debname and _(' (try installing the %s package)') % debname or '')
        )
Example #6
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 = procutil.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
            diffopts = ui.config('extdiff', 'opts.' + cmd)
            cmdline = procutil.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 = procutil.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
                cmdline = procutil.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,
                helpcategory=command.CATEGORY_FILE_CONTENTS,
                inferrepo=True)(savedcmd(path, cmdline))
Example #7
0
def uisetup(ui):
  for cmd, path in ui.configitems('extdiff2'):
    path = util.expandpath(path)
    if cmd.startswith('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('extdiff2', 'opts.' + cmd)
      cmdline = procutil.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 = procutil.findexe(cmd)
        if path is None:
          path = filemerge.findexternaltool(ui, cmd) or cmd
        cmdline = procutil.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,
            helpcategory=command.CATEGORY_FILE_CONTENTS,
            inferrepo=True)(savedcmd(path, cmdline))