Skip to content

Commit

Permalink
Merge branch 'qtpy'
Browse files Browse the repository at this point in the history
* qtpy: (216 commits)
  qtpy: make git-cola pyside-compatible
  widgets: reorder classes so that the mixin's closeEvent() takes priority
  Release 1.1.1
  Update Changelog
  Make qtpy to set the QT_API environment variable
  cola: set version to 2.7.beta
  dag: call mixing constructors explicitly
  widgets: use QtWidgets.QSpacerItem
  qtutils: use QtWidgets.QGridLayout
  pyqt4toqtpy: add QGridLayout and QSpacerItem
  Back to work
  Release 1.1.0
  Update Changelog
  Update Changelog for previous versions using the output of loghub
  xbase: add flake8-suggested whitespace
  spellcheck: move copyright to fix flake8 warnings
  grep: initial widget state setup
  finder: split long line
  diff: fix alignment
  completion: wrap long line
  ...
  • Loading branch information
davvid committed Jul 11, 2016
2 parents 09e21fb + 0eb9e65 commit 7000db6
Show file tree
Hide file tree
Showing 96 changed files with 3,915 additions and 1,638 deletions.
9 changes: 4 additions & 5 deletions .travis.yml
Expand Up @@ -18,7 +18,6 @@ before_install:

# command to install dependencies, git and python are pre-installed in build box thus are ignored
install:
- pip install sphinx
# SIP
- mkdir -p local/sandbox
- cd local/sandbox
Expand All @@ -37,13 +36,13 @@ install:
- make -j4
- make install
- cd ../../..
# Additional dependency for python 2.6
- pip install argparse
# Test dependencies
- pip install mock
# Pylint
- pip install astroid==1.4.3
- pip install pylint==1.5.2
# Build dependencies
- pip install --requirement requirements.txt
# Test dependencies
- pip install --requirement extras/requirements-dev.txt

script:
- make all
Expand Down
15 changes: 12 additions & 3 deletions Makefile
Expand Up @@ -40,9 +40,13 @@ cola_app = $(CURDIR)/$(cola_app_base)
cola_version = $(shell $(PYTHON) bin/git-cola version --brief)
cola_dist := $(cola_base)-$(cola_version)

# Allows e.g. "make test flags=--stop"
NOSE_FLAGS = --with-doctest
NOSE_FLAGS += --with-id
NOSE_FLAGS += --exclude=sphinxtogithub
NOSE_FLAGS += --exclude=extras
# Allows "make test flags=--stop"
flags =
NOSE ?= $(NOSETESTS) --with-doctest --with-id --exclude=sphinxtogithub $(flags)
NOSE ?= $(NOSETESTS) $(NOSE_FLAGS) $(flags)

SETUP ?= $(PYTHON) setup.py
setup_args += --prefix=$(prefix)
Expand All @@ -57,6 +61,11 @@ ifdef DESTDIR
endif
export prefix

# If NO_VENDOR_LIBS is specified on the command line then pass it to setup.py
ifdef NO_VENDOR_LIBS
setup_args += --no-vendor-libs
endif

PYTHON_DIRS = cola
PYTHON_DIRS += test

Expand Down Expand Up @@ -192,6 +201,6 @@ pylint:
.PHONY: pylint

requirements:
$(PIP) install --requirement extras/requirements.txt
$(PIP) install --requirement requirements.txt
$(PIP) install --requirement extras/requirements-dev.txt
.PHONY: requirements
68 changes: 44 additions & 24 deletions README.md
Expand Up @@ -42,21 +42,42 @@ New releases are available on the

# NUTRITIONAL FACTS


## ACTIVE INGREDIENTS

* [git](http://git-scm.com/) 1.6.3 or newer.

* [Python](http://python.org/) 2.6, 2.7, and 3.2 or newer.

* [PyQt4](http://www.riverbankcomputing.co.uk/software/pyqt/download) 4.4 or newer
* [QtPy](https://github.com/spyder-ide/qtpy) 1.0.2 or newer.

* [argparse](https://pypi.python.org/pypi/argparse) 1.1 or newer.
argparse is part of the stdlib in Python 2.7; install argparse separately if
you are running on Python 2.6.

* [Sphinx](http://sphinx-doc.org/) for building the documentation.

*git-cola* uses *QtPy*, so you can choose between *PyQt4*, *PyQt5*, and
*PySide* by setting the `QT_API` environment variable to `pyqt4`, `pyqt5` or
`pyside` as desired. `qtpy` defaults to `pyqt5` and falls back to `pyqt4`
if `pyqt5` is not installed.

Any of the following Python Qt libraries must be installed:

* [PyQt4](http://www.riverbankcomputing.co.uk/software/pyqt/download) 4.6 or newer

* [PyQt5](http://www.riverbankcomputing.co.uk/software/pyqt/download5) 5.2 or newer

* [PySide](https://github.com/PySide/PySide) 1.1.0 or newer

*NOTE*: *git-cola* includes a vendored copy of its *QtPy* dependency.

We provide a copy of the `qtpy` module when installing *git-cola* so that you
are not required to install *QtPy* separately. If you'd like to provide your
own `qtpy` module, for example from the `python-qtpy` Debian package, then use
`make NO_VENDOR_LIBS=1 ...` when invoking `make`, or export
`GIT_COLA_NO_VENDOR_LIBS=1` into the build environment.


## ADDITIVES

*git-cola* enables additional features when the following
Expand Down Expand Up @@ -100,10 +121,9 @@ If you want to do a global install you can do

make prefix=/usr install

There are also platform-specific installation methods.
You'll probably want to use one of these anyways since they
have a nice side-effect of installing *git-cola*'s PyQt4
and argparse dependencies.
The platform-specific installation methods below use the native
package manager. You should use one of these so that all of *git-cola*'s
dependencies are installed.

## LINUX

Expand All @@ -130,6 +150,7 @@ If not, please file a bug against your distribution ;-)

Use the [one-click install link](http://software.opensuse.org/package/git-cola).


## MAC OS X

Before setting up homebrew, use
Expand All @@ -138,7 +159,7 @@ Before setting up homebrew, use

Sphinx is used to build the documentation.

sudo pip install sphinx
sudo pip install --requirement requirements.txt

[Homebrew](http://mxcl.github.com/homebrew/) is the easiest way to install
git-cola's *Qt4* and *PyQt4* dependencies. We will use homebrew to install
Expand Down Expand Up @@ -259,11 +280,11 @@ See `git cola --help-commands` for the full list of commands.

The following commands should be run during development:

# Run the unit tests
$ make test
# Run the unit tests
$ make test

# Check for pylint warnings. All new code must pass 100%.
$ make pylint
# Check for pylint warnings. All new code must pass 100%.
$ make pylint

The test suite can be found in the [test](test) directory.

Expand All @@ -273,9 +294,9 @@ Checkout the [Travis config file](.travis.yml) for more details.

When submitting patches, consult the [contributing guidelines](CONTRIBUTING.md).

## WINDOWS (continued)
# WINDOWS (continued)

# WINDOWS-ONLY HISTORY BROWSER CONFIGURATION UPGRADE
## WINDOWS-ONLY HISTORY BROWSER CONFIGURATION UPGRADE

You may need to configure your history browser if you are upgrading from an
older version of *git-cola*.
Expand All @@ -302,25 +323,24 @@ users should not need to configure anything.
# BUILDING WINDOWS INSTALLERS

Windows installers are built using
[Pynsist](http://pynsist.readthedocs.io/en/latest/).
[NSIS](http://nsis.sourceforge.net/Main_Page) is also needed.

* [Pynsist](http://pynsist.readthedocs.io/en/latest/).

* [NSIS](http://nsis.sourceforge.net/Main_Page) is also needed.

To build the installer using *Pynsist*:

1. (If building from a non-Windows platform), run
`./contrib/win32/fetch_pyqt_windows.sh`.
This will download a PyQt binary installer for Windows and unpack its files
into `pynsist_pkgs/`.
2. Run `pynsist pynsist.cfg`.
The installer will be built in `build/nsis/`.
* If building from a non-Windows platform run
`./contrib/win32/fetch_pyqt_windows.sh`.
This will download a PyQt binary installer for Windows and unpack its files
into `pynsist_pkgs/`.

* Run `pynsist pynsist.cfg`.
The installer will be built in `build/nsis/`.

Before *Pynsist*, installers were built using *InnoSetup*.
The *InnoSetup* scripts are still available:

./contrib/win32/create-installer.sh

You have to make sure that the file */share/InnoSetup/ISCC.exe* exists.
That is normally the case when you run the *msysGit bash* and not the
*Git for Windows bash* (look [here](http://msysgit.github.com/)
for the differences).
10 changes: 4 additions & 6 deletions bin/git-dag
Expand Up @@ -53,9 +53,7 @@ def setup_environment():
setup_environment()


from cola.app import add_common_arguments
from cola.app import application_init
from cola.app import application_start
from cola import app
from cola.widgets.dag import git_dag


Expand All @@ -68,7 +66,7 @@ def parse_args():
parser = ArgumentParser()
parser.set_defaults(func=cmd_dag)

add_common_arguments(parser)
app.add_common_arguments(parser)
parser.add_argument('-c', '--count', '--max-count', metavar='<count>',
type=int, default=1000,
help='number of commits to display')
Expand All @@ -83,9 +81,9 @@ def parse_args():


def cmd_dag(args):
context = application_init(args)
context = app.application_init(args)
view = git_dag(context.model, args=args, settings=args.settings)
return application_start(context, view, monitor_refs_only=True)
return app.application_start(context, view, monitor_refs_only=True)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion cola/_version.py
@@ -1 +1 @@
VERSION = '2.6'
VERSION = '2.7.beta'
11 changes: 2 additions & 9 deletions cola/actions.py
@@ -1,10 +1,5 @@
from __future__ import absolute_import

from cola import sipcompat
sipcompat.initialize()

from PyQt4.QtCore import SIGNAL

from cola import cmds
from cola import hotkeys
from cola import icons
Expand Down Expand Up @@ -36,13 +31,11 @@ def stage_or_unstage(widget):

def move_down(widget):
return qtutils.add_action(
widget, N_('Next File'),
lambda: widget.emit(SIGNAL('move_down()')),
widget, N_('Next File'), widget.down.emit,
hotkeys.MOVE_DOWN_SECONDARY)


def move_up(widget):
return qtutils.add_action(
widget, N_('Previous File'),
lambda: widget.emit(SIGNAL('move_up()')),
widget, N_('Previous File'), widget.up.emit,
hotkeys.MOVE_UP_SECONDARY)
40 changes: 14 additions & 26 deletions cola/app.py
@@ -1,11 +1,11 @@
"""Provides the main() routine and ColaApplication"""
from __future__ import division, absolute_import, unicode_literals

import argparse
import os
import signal
import sys


__copyright__ = """
Copyright (C) 2009-2016 David Aguilar and contributors
"""
Expand All @@ -18,12 +18,6 @@
if os.path.isdir(homebrew_mods):
sys.path.append(homebrew_mods)


errmsg = """Sorry, you do not seem to have PyQt4 installed.
Please install it before using git-cola.
e.g.: sudo apt-get install python-qt4
"""

# /usr/include/sysexits.h
# #define EX_OK 0 /* successful termination */
# #define EX_USAGE 64 /* command line usage error */
Expand All @@ -34,23 +28,18 @@
EX_NOINPUT = 66
EX_UNAVAILABLE = 69


try:
from cola import sipcompat
except ImportError:
sys.stderr.write(errmsg)
sys.exit(EX_UNAVAILABLE)

sipcompat.initialize()

try:
from PyQt4 import QtCore
from qtpy import QtCore
except ImportError:
errmsg = """
Sorry, you do not seem to have PyQt5, Pyside, or PyQt4 installed.
Please install it before using git-cola, e.g.:
$ sudo apt-get install python-qt4
"""
sys.stderr.write(errmsg)
sys.exit(EX_UNAVAILABLE)

from PyQt4 import QtGui
from PyQt4.QtCore import SIGNAL
from qtpy import QtWidgets

# Import cola modules
from cola import cmds
Expand Down Expand Up @@ -79,7 +68,7 @@ def setup_environment():
signal.signal(signal.SIGINT, signal.SIG_DFL)

# Session management wants an absolute path when restarting
sys.argv[0] = sys_argv0 = core.abspath(sys.argv[0])
sys.argv[0] = sys_argv0 = os.path.abspath(sys.argv[0])

# Spoof an X11 display for SSH
os.environ.setdefault('DISPLAY', ':0')
Expand Down Expand Up @@ -162,8 +151,7 @@ def __init__(self, argv, locale=None, gui=True):
qtutils.install()
icons.install()

QtCore.QObject.connect(fsmonitor.current(), SIGNAL('files_changed'),
self._update_files)
fsmonitor.current().files_changed.connect(self._update_files)

if gui:
self._app = current(tuple(argv))
Expand Down Expand Up @@ -196,18 +184,18 @@ def current(argv):
return ColaQApplication(list(argv))


class ColaQApplication(QtGui.QApplication):
class ColaQApplication(QtWidgets.QApplication):

def __init__(self, argv):
QtGui.QApplication.__init__(self, argv)
super(ColaQApplication, self).__init__(argv)
self.view = None # injected by application_start()

def event(self, e):
if e.type() == QtCore.QEvent.ApplicationActivate:
cfg = gitcfg.current()
if cfg.get('cola.refreshonfocus', False):
cmds.do(cmds.Refresh)
return QtGui.QApplication.event(self, e)
return super(ColaQApplication, self).event(e)

def commitData(self, session_mgr):
"""Save session data"""
Expand Down Expand Up @@ -287,7 +275,7 @@ def application_start(context, view, monitor_refs_only=False):

msg_timer = QtCore.QTimer()
msg_timer.setSingleShot(True)
msg_timer.connect(msg_timer, SIGNAL('timeout()'), _send_msg)
msg_timer.timeout.connect(_send_msg)
msg_timer.start(0)

# Start the event loop
Expand Down

0 comments on commit 7000db6

Please sign in to comment.