/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
776.2.12 by Curtis Hovey
Fixed spelling, hushed lint, updated dummy cmd_build_i18n to actually run to tell
4
import os
5
import sys
6
7
from info import bzr_plugin_version
696 by Jelmer Vernooij
Start on 0.100.0.
8
288 by Jelmer Vernooij
Add check command to setup.py.
9
from distutils.core import setup, Command
0.9.1 by Stéphane Raimbault
Work on translation.
10
from distutils.command.install_data import install_data
608 by Jelmer Vernooij
Merge create-credits into setup.py.
11
from distutils.command.build import build
715.1.2 by Jelmer Vernooij
Generate pickles file for './setup.py sdist'
12
from distutils.command.sdist import sdist
696.1.4 by David Planella
Added preliminary internationalization support. Merged from trunk.
13
try:
776.2.12 by Curtis Hovey
Fixed spelling, hushed lint, updated dummy cmd_build_i18n to actually run to tell
14
    from DistUtilsExtra.command import build_i18n
696.1.4 by David Planella
Added preliminary internationalization support. Merged from trunk.
15
except ImportError:
776.2.12 by Curtis Hovey
Fixed spelling, hushed lint, updated dummy cmd_build_i18n to actually run to tell
16
    # Python distutils extra is not available.
17
    class cmd_build_i18n(build):
18
        user_options = []
19
20
        def initialize_options(self):
21
            self.domain = None
22
            self.desktop_files = None
23
24
        def finalize_options(self):
25
            pass
26
696.1.4 by David Planella
Added preliminary internationalization support. Merged from trunk.
27
        def run(self):
776.2.12 by Curtis Hovey
Fixed spelling, hushed lint, updated dummy cmd_build_i18n to actually run to tell
28
            print >> sys.stderr, (
29
                "For internationalization support you'll need to install "
30
                "https://launchpad.net/python-distutils-extra")
696.1.4 by David Planella
Added preliminary internationalization support. Merged from trunk.
31
else:
32
    # Use build_i18n from DistUtilsExtra
33
    cmd_build_i18n = build_i18n.build_i18n
34
0.9.1 by Stéphane Raimbault
Work on translation.
35
288 by Jelmer Vernooij
Add check command to setup.py.
36
class Check(Command):
37
    description = "Run unit tests"
38
776.1.6 by Curtis Hovey
Added a test module for ui.
39
    user_options = [
40
        ('module=', 'm', 'The test module to run'),
41
        ]
288 by Jelmer Vernooij
Add check command to setup.py.
42
43
    def initialize_options(self):
779.1.1 by Curtis Hovey
Support selftest, check, and check -m
44
        self.module = None
288 by Jelmer Vernooij
Add check command to setup.py.
45
46
    def finalize_options(self):
47
        pass
48
49
    def get_command_name(self):
50
        return 'test'
51
52
    def run(self):
53
        from bzrlib.tests import TestLoader, TestSuite, TextTestRunner
715.1.1 by Jelmer Vernooij
Fix setup.py check.
54
        from bzrlib.plugin import PluginImporter
776.2.12 by Curtis Hovey
Fixed spelling, hushed lint, updated dummy cmd_build_i18n to actually run to tell
55
        PluginImporter.specific_paths["bzrlib.plugins.gtk"] = os.path.dirname(
56
            __file__)
715.1.1 by Jelmer Vernooij
Fix setup.py check.
57
        from bzrlib.plugins.gtk.tests import load_tests
58
        suite = TestSuite()
59
        loader = TestLoader()
776.1.6 by Curtis Hovey
Added a test module for ui.
60
        load_tests(suite, self.module, loader)
288 by Jelmer Vernooij
Add check command to setup.py.
61
        runner = TextTestRunner()
62
        result = runner.run(suite)
63
        return result.wasSuccessful()
64
608 by Jelmer Vernooij
Merge create-credits into setup.py.
65
66
class CreateCredits(Command):
67
    description = "Create credits file"
68
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
69
    user_options = [("url=", None, "URL of branch")]
608 by Jelmer Vernooij
Merge create-credits into setup.py.
70
71
    def initialize_options(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
72
        self.url = "."
608 by Jelmer Vernooij
Merge create-credits into setup.py.
73
74
    def finalize_options(self):
75
        pass
76
77
    def get_command_name(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
78
        return 'build_credits'
608 by Jelmer Vernooij
Merge create-credits into setup.py.
79
80
    def run(self):
776.2.12 by Curtis Hovey
Fixed spelling, hushed lint, updated dummy cmd_build_i18n to actually run to tell
81
        from bzrlib.plugin import load_plugins
82
        load_plugins()
608 by Jelmer Vernooij
Merge create-credits into setup.py.
83
        from bzrlib.branch import Branch
692 by Jelmer Vernooij
Cope with find_credits moving.
84
        from bzrlib.plugins.stats.cmds import find_credits
608 by Jelmer Vernooij
Merge create-credits into setup.py.
85
86
        import pickle
87
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
88
        branch = Branch.open(self.url)
608 by Jelmer Vernooij
Merge create-credits into setup.py.
89
        credits = find_credits(branch.repository, branch.last_revision())
90
91
        pickle.dump(credits, file("credits.pickle", 'w'))
92
        return True
93
94
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
95
def is_versioned(cmd):
611 by Jelmer Vernooij
Fix import.
96
    from bzrlib.errors import NotBranchError
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
97
    try:
98
        from bzrlib.branch import Branch
99
        Branch.open(".")
100
        return True
101
    except NotBranchError:
102
        return False
103
104
608 by Jelmer Vernooij
Merge create-credits into setup.py.
105
class BuildData(build):
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
106
    sub_commands = build.sub_commands[:]
107
    sub_commands.append(('build_credits', is_versioned))
608 by Jelmer Vernooij
Merge create-credits into setup.py.
108
109
715.1.2 by Jelmer Vernooij
Generate pickles file for './setup.py sdist'
110
class SourceDist(sdist):
111
    sub_commands = sdist.sub_commands[:]
112
    sub_commands.append(('build_credits', is_versioned))
113
114
0.9.1 by Stéphane Raimbault
Work on translation.
115
class InstallData(install_data):
676 by Jelmer Vernooij
Fix missing import.
116
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
117
    def run(self):
676 by Jelmer Vernooij
Fix missing import.
118
        import subprocess
463 by Martin Albisetti
Enable default nautilus integration
119
        self.data_files.extend(self._nautilus_plugin())
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
120
        install_data.run(self)
441 by Martin Albisetti
Added checking that the install enviroment is Linux before updating the icon cache
121
442 by Martin Albisetti
Check if command exists first before updating the cache to support all platforms
122
        try:
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
123
            subprocess.check_call('gtk-update-icon-cache '
124
                                  '-f -t /usr/share/icons/hicolor')
676 by Jelmer Vernooij
Fix missing import.
125
        except OSError:
442 by Martin Albisetti
Check if command exists first before updating the cache to support all platforms
126
            pass
440 by Martin Albisetti
Install new bzr icons (emblems) and update the icon cache
127
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
128
    def _nautilus_plugin(self):
129
        files = []
130
        if sys.platform[:5] == 'linux':
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
131
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python',
132
                           'r')
560.7.1 by Daniel Schömer
Strip newline from nautilus-python pythondir read from pkg-config.
133
            res = cmd.readline().strip()
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
134
            ret = cmd.close()
135
            if ret is None:
136
                dest = res[5:]
137
                files.append((dest, ['nautilus-bzr.py']))
138
        return files
83 by Jelmer Vernooij
Merge Olive code.
139
140
682.1.1 by Robert Collins
Guard setup.py
141
if __name__ == '__main__':
696 by Jelmer Vernooij
Start on 0.100.0.
142
    version = bzr_plugin_version[:3]
143
    version_string = ".".join([str(x) for x in version])
682.1.1 by Robert Collins
Guard setup.py
144
    setup(
776.2.12 by Curtis Hovey
Fixed spelling, hushed lint, updated dummy cmd_build_i18n to actually run to tell
145
        name="bzr-gtk",
146
        version=version_string,
147
        maintainer="Jelmer Vernooij",
148
        maintainer_email="jelmer@samba.org",
149
        description="GTK+ Frontends for various Bazaar commands",
150
        license="GNU GPL v2 or later",
151
        scripts=['bzr-handle-patch', 'bzr-notify'],
152
        url="http://bazaar-vcs.org/BzrGtk",
153
        package_dir={
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
154
            "bzrlib.plugins.gtk": ".",
155
            "bzrlib.plugins.gtk.viz": "viz",
156
            "bzrlib.plugins.gtk.annotate": "annotate",
157
            "bzrlib.plugins.gtk.tests": "tests",
158
            "bzrlib.plugins.gtk.branchview": "branchview",
159
            "bzrlib.plugins.gtk.preferences": "preferences",
160
            },
776.2.12 by Curtis Hovey
Fixed spelling, hushed lint, updated dummy cmd_build_i18n to actually run to tell
161
        packages=[
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
162
            "bzrlib.plugins.gtk",
163
            "bzrlib.plugins.gtk.viz",
164
            "bzrlib.plugins.gtk.annotate",
165
            "bzrlib.plugins.gtk.tests",
166
            "bzrlib.plugins.gtk.branchview",
167
            "bzrlib.plugins.gtk.preferences",
83 by Jelmer Vernooij
Merge Olive code.
168
        ],
776.2.12 by Curtis Hovey
Fixed spelling, hushed lint, updated dummy cmd_build_i18n to actually run to tell
169
        data_files=[('share/bzr-gtk', ['credits.pickle']),
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
170
                    ('share/bzr-gtk/icons', ['icons/commit.png',
171
                                             'icons/commit16.png',
172
                                             'icons/diff.png',
173
                                             'icons/diff16.png',
174
                                             'icons/log.png',
175
                                             'icons/log16.png',
176
                                             'icons/pull.png',
177
                                             'icons/pull16.png',
178
                                             'icons/push.png',
179
                                             'icons/push16.png',
180
                                             'icons/refresh.png',
181
                                             'icons/sign-bad.png',
182
                                             'icons/sign-ok.png',
183
                                             'icons/sign.png',
184
                                             'icons/sign-unknown.png',
185
                                             'icons/tag-16.png',
186
                                             'icons/bug.png',
187
                                             'icons/bzr-icon-64.png']),
696.1.4 by David Planella
Added preliminary internationalization support. Merged from trunk.
188
                    # In case Python distutils extra is not available,
189
                    # install the .desktop files
688.2.1 by Jelmer Vernooij
Split out olive into a separate directory.
190
                    ('share/applications', ['bazaar-properties.desktop',
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
191
                                            'bzr-handle-patch.desktop',
192
                                            'bzr-notify.desktop']),
748 by Jelmer Vernooij
Fix typo in setup.py.
193
                    ('share/application-registry', ['bzr-gtk.applications']),
699.2.5 by Andrew Starr-Bochicchio
Install bzr-panel to share/icons/hicolor/scalable/apps
194
                    ('share/pixmaps', ['icons/bzr-icon-64.png']),
776.2.12 by Curtis Hovey
Fixed spelling, hushed lint, updated dummy cmd_build_i18n to actually run to tell
195
                    ('share/icons/hicolor/scalable/apps',
196
                        ['icons/bzr-panel.svg']),
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
197
                    ('share/icons/hicolor/scalable/emblems',
198
                     ['icons/emblem-bzr-added.svg',
199
                      'icons/emblem-bzr-conflict.svg',
200
                      'icons/emblem-bzr-controlled.svg',
201
                      'icons/emblem-bzr-modified.svg',
202
                      'icons/emblem-bzr-removed.svg',
203
                      'icons/emblem-bzr-ignored.svg'])
204
                    ],
205
        cmdclass={'install_data': InstallData,
206
                  'build_credits': CreateCredits,
207
                  'build': BuildData,
696.1.4 by David Planella
Added preliminary internationalization support. Merged from trunk.
208
                  'build_i18n': cmd_build_i18n,
715.1.2 by Jelmer Vernooij
Generate pickles file for './setup.py sdist'
209
                  'sdist': SourceDist,
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
210
                  'check': Check}
211
        )