/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/usr/bin/python
"""GTK+ Frontends for various Bazaar commands."""

import os
import sys

from info import bzr_plugin_version

from distutils.core import setup, Command
from distutils.command.install_data import install_data
from distutils.command.build import build
from distutils.command.sdist import sdist
try:
    from DistUtilsExtra.command import build_i18n
except ImportError:
    # Python distutils extra is not available.
    class cmd_build_i18n(build):
        user_options = []

        def initialize_options(self):
            self.domain = None
            self.desktop_files = None

        def finalize_options(self):
            pass

        def run(self):
            print >> sys.stderr, (
                "For internationalization support you'll need to install "
                "https://launchpad.net/python-distutils-extra")
else:
    # Use build_i18n from DistUtilsExtra
    cmd_build_i18n = build_i18n.build_i18n


class Check(Command):
    description = "Run unit tests"

    user_options = [
        ('module=', 'm', 'The test module to run'),
        ]

    def initialize_options(self):
        self.module = None

    def finalize_options(self):
        pass

    def get_command_name(self):
        return 'test'

    def run(self):
        from bzrlib.tests import TestLoader, TestSuite, TextTestRunner
        from bzrlib.plugin import PluginImporter
        PluginImporter.specific_paths["bzrlib.plugins.gtk"] = os.path.dirname(
            __file__)
        from bzrlib.plugins.gtk.tests import load_tests
        suite = TestSuite()
        loader = TestLoader()
        load_tests(suite, self.module, loader)
        runner = TextTestRunner()
        result = runner.run(suite)
        return result.wasSuccessful()


class CreateCredits(Command):
    description = "Create credits file"

    user_options = [("url=", None, "URL of branch")]

    def initialize_options(self):
        self.url = "."

    def finalize_options(self):
        pass

    def get_command_name(self):
        return 'build_credits'

    def run(self):
        from bzrlib.plugin import load_plugins
        load_plugins()
        from bzrlib.branch import Branch
        from bzrlib.plugins.stats.cmds import find_credits

        import pickle

        branch = Branch.open(self.url)
        credits = find_credits(branch.repository, branch.last_revision())

        pickle.dump(credits, file("credits.pickle", 'w'))
        return True


def is_versioned(cmd):
    from bzrlib.errors import NotBranchError
    try:
        from bzrlib.branch import Branch
        Branch.open(".")
        return True
    except NotBranchError:
        return False


class BuildData(build):
    sub_commands = build.sub_commands[:]
    sub_commands.append(('build_credits', is_versioned))


class SourceDist(sdist):
    sub_commands = sdist.sub_commands[:]
    sub_commands.append(('build_credits', is_versioned))


class InstallData(install_data):

    def run(self):
        import subprocess
        self.data_files.extend(self._nautilus_plugin())
        install_data.run(self)

        try:
            subprocess.check_call('gtk-update-icon-cache '
                                  '-f -t /usr/share/icons/hicolor')
        except OSError:
            pass

    def _nautilus_plugin(self):
        files = []
        if sys.platform[:5] == 'linux':
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python',
                           'r')
            res = cmd.readline().strip()
            ret = cmd.close()
            if ret is None:
                dest = res[5:]
                files.append((dest, ['nautilus-bzr.py']))
        return files


if __name__ == '__main__':
    version = bzr_plugin_version[:3]
    version_string = ".".join([str(x) for x in version])
    setup(
        name="bzr-gtk",
        version=version_string,
        maintainer="Jelmer Vernooij",
        maintainer_email="jelmer@samba.org",
        description="GTK+ Frontends for various Bazaar commands",
        license="GNU GPL v2 or later",
        scripts=['bzr-handle-patch'],
        url="http://bazaar-vcs.org/BzrGtk",
        package_dir={
            "bzrlib.plugins.gtk": ".",
            "bzrlib.plugins.gtk.viz": "viz",
            "bzrlib.plugins.gtk.annotate": "annotate",
            "bzrlib.plugins.gtk.tests": "tests",
            "bzrlib.plugins.gtk.branchview": "branchview",
            "bzrlib.plugins.gtk.preferences": "preferences",
            },
        packages=[
            "bzrlib.plugins.gtk",
            "bzrlib.plugins.gtk.viz",
            "bzrlib.plugins.gtk.annotate",
            "bzrlib.plugins.gtk.tests",
            "bzrlib.plugins.gtk.branchview",
            "bzrlib.plugins.gtk.preferences",
        ],
        data_files=[('share/bzr-gtk', ['credits.pickle']),
                    ('share/bzr-gtk/icons', ['icons/commit.png',
                                             'icons/commit16.png',
                                             'icons/diff.png',
                                             'icons/diff16.png',
                                             'icons/log.png',
                                             'icons/log16.png',
                                             'icons/pull.png',
                                             'icons/pull16.png',
                                             'icons/push.png',
                                             'icons/push16.png',
                                             'icons/refresh.png',
                                             'icons/sign-bad.png',
                                             'icons/sign-ok.png',
                                             'icons/sign.png',
                                             'icons/sign-unknown.png',
                                             'icons/tag-16.png',
                                             'icons/bug.png',
                                             'icons/bzr-icon-64.png']),
                    # In case Python distutils extra is not available,
                    # install the .desktop files
                    ('share/applications', ['bazaar-properties.desktop',
                                            'bzr-handle-patch.desktop']),
                    ('share/application-registry', ['bzr-gtk.applications']),
                    ('share/pixmaps', ['icons/bzr-icon-64.png']),
                    ('share/icons/hicolor/scalable/apps',
                        ['icons/bzr-panel.svg']),
                    ('share/icons/hicolor/scalable/emblems',
                     ['icons/emblem-bzr-added.svg',
                      'icons/emblem-bzr-conflict.svg',
                      'icons/emblem-bzr-controlled.svg',
                      'icons/emblem-bzr-modified.svg',
                      'icons/emblem-bzr-removed.svg',
                      'icons/emblem-bzr-ignored.svg'])
                    ],
        cmdclass={'install_data': InstallData,
                  'build_credits': CreateCredits,
                  'build': BuildData,
                  'build_i18n': cmd_build_i18n,
                  'sdist': SourceDist,
                  'check': Check}
        )