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