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