Exemplo n.º 1
0
def _common_diff_opts(config=config):
    # The '--patience' option did not appear until git 1.6.2
    # so don't allow it to be used on version previous to that
    patience = version.check('patience', version.git_version())
    submodule = version.check('diff-submodule', version.git_version())
    return {
        'patience': patience,
        'submodule': submodule,
        'no_color': True,
        'no_ext_diff': True,
        'with_raw_output': True,
        'with_stderr': True,
        'unified': config.get('gui.diffcontext', 3),
    }
Exemplo n.º 2
0
def _run_setup():
    """Runs distutils.setup()"""

    scripts = ['bin/git-cola']

    # git-difftool first moved out of git.git's contrib area in git 1.6.3
    if (os.environ.get('INSTALL_GIT_DIFFTOOL', '') or
            not version.check('difftool-builtin', version.git_version())):
        scripts.append('bin/difftool/git-difftool')
        scripts.append('bin/difftool/git-difftool--helper')

    if sys.platform == 'win32':
        scripts.append('win32/cola')
        scripts.append('win32/dirname')
        scripts.append('win32/py2exe-setup.py')
        scripts.append('win32/py2exe-setup.cmd')

    setup(name = 'git-cola',
          version = version.version(),
          description = 'A highly caffeinated git GUI',
          license = 'GPLv2',
          author = 'The git-cola community',
          author_email = '*****@*****.**',
          url = 'http://cola.tuxfamily.org/',
          long_description = 'A highly caffeinated git GUI',
          scripts = scripts,
          cmdclass = cmdclass,
          data_files = cola_data_files())
Exemplo n.º 3
0
def _check_git_version():
    """Check the minimum GIT version
    """
    git_version = version.git_version()
    if not version.check('git', git_version):
        print >> sys.stderr, ('GIT version %s or newer required.  '
                              'Found %s' % (version.get('git'), git_version))
        sys.exit(1)
Exemplo n.º 4
0
def _check_git_version():
    """Check the minimum GIT version
    """
    git_version = version.git_version()
    if not version.check('git', git_version):
        print >> sys.stderr, ('GIT version %s or newer required.  '
                              'Found %s' % (version.get('git'), git_version))
        sys.exit(1)
Exemplo n.º 5
0
 def do(self):
     if not self.paths:
         return
     if version.check('mergetool-no-prompt',
                      self.model.git.version().split()[-1]):
         utils.fork(['git', 'mergetool', '--no-prompt', '--'] + self.paths)
     else:
         utils.fork(['xterm', '-e', 'git', 'mergetool', '--'] + self.paths)
Exemplo n.º 6
0
def _check_python_version():
    """Check the minimum Python version
    """
    pyver = platform.python_version()
    if not version.check('python', pyver):
        print >> sys.stderr, ('Python version %s or newer required.  '
                              'Found %s' % (version.get('python'), pyver))
        sys.exit(1)
Exemplo n.º 7
0
def _check_python_version():
    """Check the minimum Python version
    """
    pyver = '.'.join(map(lambda x: str(x), sys.version_info))
    if not version.check('python', pyver):
        print >> sys.stderr, ('Python version %s or newer required.  '
                              'Found %s' % (version.get('python'), pyver))
        sys.exit(1)
Exemplo n.º 8
0
def _check_python_version():
    """Check the minimum Python version
    """
    pyver = platform.python_version()
    if not version.check('python', pyver):
        print >> sys.stderr, ('Python version %s or newer required.  '
                              'Found %s' % (version.get('python'), pyver))
        sys.exit(1)
Exemplo n.º 9
0
def _common_diff_opts(config=config):
    submodule = version.check("diff-submodule", version.git_version())
    return {
        "patience": True,
        "submodule": submodule,
        "no_color": True,
        "no_ext_diff": True,
        "with_raw_output": True,
        "with_stderr": True,
        "unified": config.get("gui.diffcontext", 3),
    }
Exemplo n.º 10
0
def _common_diff_opts(config=config):
    submodule = version.check('diff-submodule', version.git_version())
    return {
        'patience': True,
        'submodule': submodule,
        'no_color': True,
        'no_ext_diff': True,
        'with_raw_output': True,
        'with_stderr': True,
        'unified': config.get('gui.diffcontext', 3),
    }
Exemplo n.º 11
0
def _common_diff_opts(config=config):
    submodule = version.check('diff-submodule', version.git_version())
    return {
        'patience': True,
        'submodule': submodule,
        'no_color': True,
        'no_ext_diff': True,
        'with_raw_output': True,
        'with_stderr': True,
        'unified': config.get('gui.diffcontext', 3),
    }
Exemplo n.º 12
0
def common_diff_opts(config=config):
    submodule = version.check('diff-submodule', version.git_version())
    opts = {
        'patience': True,
        'submodule': submodule,
        'no_color': True,
        'no_ext_diff': True,
        'unified': config.get('gui.diffcontext', 3),
        '_raw': True,
    }
    opts.update(_diff_overrides)
    return opts
Exemplo n.º 13
0
def common_diff_opts(config=config):
    submodule = version.check("diff-submodule", version.git_version())
    opts = {
        "patience": True,
        "submodule": submodule,
        "no_color": True,
        "no_ext_diff": True,
        "unified": config.get("gui.diffcontext", 3),
        "_raw": True,
    }
    opts.update(_diff_overrides)
    return opts
Exemplo n.º 14
0
def common_diff_opts(config=config):
    submodule = version.check('diff-submodule', version.git_version())
    opts = {
        'patience': True,
        'submodule': submodule,
        'no_color': True,
        'no_ext_diff': True,
        'unified': config.get('gui.diffcontext', 3),
        '_raw': True,
    }
    opts.update(_diff_overrides)
    return opts
Exemplo n.º 15
0
def _check_pyqt_version():
    """Check the minimum PyQt version
    """
    pyqtver = 'None'
    try:
        from PyQt4 import QtCore
        pyqtver = QtCore.PYQT_VERSION_STR
        if version.check('pyqt', pyqtver):
            return
    except ImportError:
        pass
    print >> sys.stderr, ('PyQt4 version %s or newer required.  '
                          'Found %s' % (version.get('pyqt'), pyqtver))
    sys.exit(1)
Exemplo n.º 16
0
def _check_pyqt_version():
    """Check the minimum PyQt version
    """
    pyqtver = 'None'
    try:
        from PyQt4 import QtCore
        pyqtver = QtCore.PYQT_VERSION_STR
        if version.check('pyqt', pyqtver):
            return
    except ImportError:
        pass
    print >> sys.stderr, ('PyQt4 version %s or newer required.  '
                          'Found %s' % (version.get('pyqt'), pyqtver))
    sys.exit(1)
Exemplo n.º 17
0
def _check_jsonpickle_version():
    """Check the minimum jsonpickle version
    """
    jsonpicklever = 'None'
    try:
        import jsonpickle
        jsonpicklever = jsonpickle.__version__
        if version.check('jsonpickle', jsonpicklever):
            return
    except ImportError:
        pass
    print >> sys.stderr, ('jsonpickle version %s or newer required.  '
                          'Found %s' % (version.get('jsonpickle'),
                                        jsonpicklever))
    sys.exit(1)
Exemplo n.º 18
0
        """Starts a GitRepoInfoTask to calculate info for entries."""
        # GitRepoInfoTask handles expensive lookups
        task = GitRepoInfoTask(self.path)
        TaskRunner.instance().run(task)

    def event(self, e):
        """Receive GitRepoInfoEvents and emit corresponding Qt signals."""
        if e.type() == INFO_EVENT_TYPE:
            e.accept()
            self.emit(SIGNAL(e.signal), *e.data)
            return True
        return QtCore.QObject.event(self, e)


# Support older versions of PyQt
if version.check('pyqt_qrunnable', QtCore.PYQT_VERSION_STR):
    QRunnable = QtCore.QRunnable
else:

    class QRunnable(object):
        pass


class GitRepoInfoTask(QRunnable):
    """Handles expensive git lookups for a path."""
    def __init__(self, path):
        QRunnable.__init__(self)
        self.path = path
        self._cfg = gitcfg.instance()
        self._data = {}
Exemplo n.º 19
0
            return
        threadpool = QtCore.QThreadPool.globalInstance()
        self.task = GitRepoInfoTask(self.path)
        threadpool.start(self.task)

    def event(self, e):
        """Receive GitRepoInfoEvents and emit corresponding Qt signals."""
        if e.type() == INFO_EVENT_TYPE:
            e.accept()
            self.emit(SIGNAL(e.signal), *e.data)
            return True
        return QtCore.QObject.event(self, e)


# Support older versions of PyQt
if version.check('pyqt_qrunnable', QtCore.PYQT_VERSION_STR):
    QRunnable = QtCore.QRunnable
else:
    class QRunnable(object):
        pass

class GitRepoInfoTask(QRunnable):
    """Handles expensive git lookups for a path."""
    def __init__(self, path):
        QRunnable.__init__(self)
        self.path = path
        self._data = {}

    def data(self, key):
        """
        Return git data for a path.
Exemplo n.º 20
0
def diff_helper(commit=None,
                branch=None,
                ref=None,
                endref=None,
                filename=None,
                cached=True,
                with_diff_header=False,
                suppress_header=True,
                reverse=False):
    "Invokes git diff on a filepath."
    if commit:
        ref, endref = commit+'^', commit
    argv = []
    if ref and endref:
        argv.append('%s..%s' % (ref, endref))
    elif ref:
        for r in ref.strip().split():
            argv.append(r)
    elif branch:
        argv.append(branch)

    if filename:
        argv.append('--')
        if type(filename) is list:
            argv.extend(filename)
        else:
            argv.append(filename)

    start = False
    del_tag = 'deleted file mode '

    headers = []
    deleted = cached and not os.path.exists(core.encode(filename))

    # The '--patience' option did not appear until git 1.6.2
    # so don't allow it to be used on version previous to that
    patience = version.check('patience', version.git_version())

    diffoutput = git.diff(R=reverse,
                          M=True,
                          no_color=True,
                          cached=cached,
                          unified=config.get('diff.context', 3),
                          with_raw_output=True,
                          with_stderr=True,
                          patience=patience,
                          *argv)

    # Handle 'git init'
    if diffoutput.startswith('fatal:'):
        if with_diff_header:
            return ('', '')
        else:
            return ''

    output = StringIO()

    diff = diffoutput.split('\n')
    for line in map(core.decode, diff):
        if not start and '@@' == line[:2] and '@@' in line[2:]:
            start = True
        if start or (deleted and del_tag in line):
            output.write(core.encode(line) + '\n')
        else:
            if with_diff_header:
                headers.append(core.encode(line))
            elif not suppress_header:
                output.write(core.encode(line) + '\n')

    result = core.decode(output.getvalue())
    output.close()

    if with_diff_header:
        return('\n'.join(headers), result)
    else:
        return result