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