/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
126.1.31 by Szilveszter Farkas (Phanatic)
We also support other versions than 2.4.
1
#!/usr/bin/python
83 by Jelmer Vernooij
Merge Olive code.
2
"""GTK+ Frontends for various Bazaar commands."""
0.8.10 by Szilveszter Farkas (Phanatic)
2006-07-16 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
3
696 by Jelmer Vernooij
Start on 0.100.0.
4
from info import *
5
288 by Jelmer Vernooij
Add check command to setup.py.
6
from distutils.core import setup, Command
0.9.1 by Stéphane Raimbault
Work on translation.
7
from distutils.command.install_data import install_data
608 by Jelmer Vernooij
Merge create-credits into setup.py.
8
from distutils.command.build import build
0.9.1 by Stéphane Raimbault
Work on translation.
9
import os
0.8.74 by Szilveszter Farkas (Phanatic)
Fix the Win32 build/install issue.
10
import sys
0.9.1 by Stéphane Raimbault
Work on translation.
11
288 by Jelmer Vernooij
Add check command to setup.py.
12
class Check(Command):
13
    description = "Run unit tests"
14
15
    user_options = []
16
17
    def initialize_options(self):
18
        pass
19
20
    def finalize_options(self):
21
        pass
22
23
    def get_command_name(self):
24
        return 'test'
25
26
    def run(self):
27
        from bzrlib.tests import TestLoader, TestSuite, TextTestRunner
28
        import __init__ as bzrgtk
29
        runner = TextTestRunner()
30
        loader = TestLoader()
31
        suite = TestSuite()
32
        suite.addTest(bzrgtk.test_suite())
33
        result = runner.run(suite)
34
        return result.wasSuccessful()
35
608 by Jelmer Vernooij
Merge create-credits into setup.py.
36
37
class CreateCredits(Command):
38
    description = "Create credits file"
39
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
40
    user_options = [("url=", None, "URL of branch")]
608 by Jelmer Vernooij
Merge create-credits into setup.py.
41
42
    def initialize_options(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
43
        self.url = "."
608 by Jelmer Vernooij
Merge create-credits into setup.py.
44
45
    def finalize_options(self):
46
        pass
47
48
    def get_command_name(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
49
        return 'build_credits'
608 by Jelmer Vernooij
Merge create-credits into setup.py.
50
51
    def run(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
52
        from bzrlib.plugin import load_plugins; load_plugins()
608 by Jelmer Vernooij
Merge create-credits into setup.py.
53
        from bzrlib.branch import Branch
692 by Jelmer Vernooij
Cope with find_credits moving.
54
        from bzrlib.plugins.stats.cmds import find_credits
608 by Jelmer Vernooij
Merge create-credits into setup.py.
55
56
        import pickle
57
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
58
        branch = Branch.open(self.url)
608 by Jelmer Vernooij
Merge create-credits into setup.py.
59
        credits = find_credits(branch.repository, branch.last_revision())
60
61
        pickle.dump(credits, file("credits.pickle", 'w'))
62
        return True
63
64
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
65
def is_versioned(cmd):
611 by Jelmer Vernooij
Fix import.
66
    from bzrlib.errors import NotBranchError
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
67
    try:
68
        from bzrlib.branch import Branch
69
        Branch.open(".")
70
        return True
71
    except NotBranchError:
72
        return False
73
74
608 by Jelmer Vernooij
Merge create-credits into setup.py.
75
class BuildData(build):
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
76
    sub_commands = build.sub_commands[:]
77
    sub_commands.append(('build_credits', is_versioned))
608 by Jelmer Vernooij
Merge create-credits into setup.py.
78
79
0.9.1 by Stéphane Raimbault
Work on translation.
80
class InstallData(install_data):
676 by Jelmer Vernooij
Fix missing import.
81
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
82
    def run(self):
676 by Jelmer Vernooij
Fix missing import.
83
        import subprocess
463 by Martin Albisetti
Enable default nautilus integration
84
        self.data_files.extend(self._nautilus_plugin())
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
85
        install_data.run(self)
441 by Martin Albisetti
Added checking that the install enviroment is Linux before updating the icon cache
86
442 by Martin Albisetti
Check if command exists first before updating the cache to support all platforms
87
        try:
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
88
            subprocess.check_call('gtk-update-icon-cache '
89
                                  '-f -t /usr/share/icons/hicolor')
676 by Jelmer Vernooij
Fix missing import.
90
        except OSError:
442 by Martin Albisetti
Check if command exists first before updating the cache to support all platforms
91
            pass
440 by Martin Albisetti
Install new bzr icons (emblems) and update the icon cache
92
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
93
    def _nautilus_plugin(self):
94
        files = []
95
        if sys.platform[:5] == 'linux':
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
96
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python',
97
                           'r')
560.7.1 by Daniel Schömer
Strip newline from nautilus-python pythondir read from pkg-config.
98
            res = cmd.readline().strip()
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
99
            ret = cmd.close()
100
            if ret is None:
101
                dest = res[5:]
102
                files.append((dest, ['nautilus-bzr.py']))
103
        return files
83 by Jelmer Vernooij
Merge Olive code.
104
105
682.1.1 by Robert Collins
Guard setup.py
106
if __name__ == '__main__':
696 by Jelmer Vernooij
Start on 0.100.0.
107
    version = bzr_plugin_version[:3]
108
    version_string = ".".join([str(x) for x in version])
682.1.1 by Robert Collins
Guard setup.py
109
    setup(
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
110
        name = "bzr-gtk",
696 by Jelmer Vernooij
Start on 0.100.0.
111
        version = version_string,
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
112
        maintainer = "Jelmer Vernooij",
113
        maintainer_email = "jelmer@samba.org",
114
        description = "GTK+ Frontends for various Bazaar commands",
115
        license = "GNU GPL v2 or later",
688.2.1 by Jelmer Vernooij
Split out olive into a separate directory.
116
        scripts = ['bzr-handle-patch', 'bzr-notify'],
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
117
        url = "http://bazaar-vcs.org/BzrGtk",
118
        package_dir = {
119
            "bzrlib.plugins.gtk": ".",
120
            "bzrlib.plugins.gtk.viz": "viz",
121
            "bzrlib.plugins.gtk.annotate": "annotate",
122
            "bzrlib.plugins.gtk.tests": "tests",
123
            "bzrlib.plugins.gtk.branchview": "branchview",
124
            "bzrlib.plugins.gtk.preferences": "preferences",
125
            },
126
        packages = [
127
            "bzrlib.plugins.gtk",
128
            "bzrlib.plugins.gtk.viz",
129
            "bzrlib.plugins.gtk.annotate",
130
            "bzrlib.plugins.gtk.tests",
131
            "bzrlib.plugins.gtk.branchview",
132
            "bzrlib.plugins.gtk.preferences",
83 by Jelmer Vernooij
Merge Olive code.
133
        ],
688.2.1 by Jelmer Vernooij
Split out olive into a separate directory.
134
        data_files=[ ('share/bzr-gtk', ['credits.pickle']),
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
135
                    ('share/bzr-gtk/icons', ['icons/commit.png',
136
                                             'icons/commit16.png',
137
                                             'icons/diff.png',
138
                                             'icons/diff16.png',
139
                                             'icons/log.png',
140
                                             'icons/log16.png',
141
                                             'icons/pull.png',
142
                                             'icons/pull16.png',
143
                                             'icons/push.png',
144
                                             'icons/push16.png',
145
                                             'icons/refresh.png',
146
                                             'icons/sign-bad.png',
147
                                             'icons/sign-ok.png',
148
                                             'icons/sign.png',
149
                                             'icons/sign-unknown.png',
150
                                             'icons/tag-16.png',
151
                                             'icons/bug.png',
152
                                             'icons/bzr-icon-64.png']),
688.2.1 by Jelmer Vernooij
Split out olive into a separate directory.
153
                    ('share/applications', ['bazaar-properties.desktop',
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
154
                                            'bzr-handle-patch.desktop',
155
                                            'bzr-notify.desktop']),
156
                    ('share/application-registry', ['bzr-gtk.applications']),
688.2.1 by Jelmer Vernooij
Split out olive into a separate directory.
157
                    ('share/pixmaps', ['icons/bzr-icon-64.png']),
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
158
                    ('share/icons/hicolor/scalable/emblems',
159
                     ['icons/emblem-bzr-added.svg',
160
                      'icons/emblem-bzr-conflict.svg',
161
                      'icons/emblem-bzr-controlled.svg',
162
                      'icons/emblem-bzr-modified.svg',
163
                      'icons/emblem-bzr-removed.svg',
164
                      'icons/emblem-bzr-ignored.svg'])
165
                    ],
166
        cmdclass={'install_data': InstallData,
167
                  'build_credits': CreateCredits,
168
                  'build': BuildData,
169
                  'check': Check}
170
        )