/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to nautilus-bzr.py

  • Committer: Daniel Schierbeck
  • Date: 2007-12-06 23:37:06 UTC
  • mto: This revision was merged to the branch mainline in revision 417.
  • Revision ID: daniel.schierbeck@gmail.com-20071206233706-eeinks66w86r3gfm
Fixed bug in gmissing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Trivial Bazaar plugin for Nautilus
 
2
#
 
3
# Copyright (C) 2006 Jeff Bailey
 
4
# Copyright (C) 2006 Wouter van Heyst
 
5
# Copyright (C) 2006 Jelmer Vernooij
 
6
#
 
7
# Published under the GNU GPL
 
8
 
1
9
import nautilus
2
10
import bzrlib
3
11
from bzrlib.bzrdir import BzrDir
4
12
from bzrlib.errors import NotBranchError
5
13
from bzrlib.workingtree import WorkingTree
 
14
from bzrlib.tree import file_status
6
15
 
7
16
from bzrlib.plugin import load_plugins
8
17
load_plugins()
9
18
 
10
19
from bzrlib.plugins.gtk import cmd_visualise, cmd_gannotate
11
20
 
12
 
class BzrExtension(nautilus.MenuProvider):
 
21
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider):
13
22
    def __init__(self):
14
23
        pass
15
24
 
69
78
        except NotBranchError:
70
79
            return
71
80
 
72
 
        from bzrlib.plugins.gtk.viz.diffwin import DiffWindow
 
81
        from bzrlib.plugins.gtk.viz.diff import DiffWindow
73
82
        window = DiffWindow()
74
 
        window.set_diff(tree.branch, tree, tree.branch.revision_tree())
 
83
        window.set_diff(tree.branch.nick, tree, tree.branch.basis_tree())
75
84
        window.show()
76
85
 
77
86
        return
117
126
        if vfs_file.get_uri_scheme() != 'file':
118
127
            return
119
128
 
120
 
        file = vfs_file.get_uri()
121
 
        try:
122
 
            tree, path = WorkingTree.open_containing(file)
123
 
        except NotBranchError:
124
 
            return
125
 
 
126
 
        from bzrlib.plugins.gtk.clone import CloneDialog
127
 
        dialog = CloneDialog(file)
128
 
        if dialog.run() != gtk.RESPONSE_CANCEL:
129
 
            bzrdir = BzrDir.open(dialog.url)
130
 
            bzrdir.sprout(dialog.dest_path)
 
129
        from bzrlib.plugins.gtk.branch import BranchDialog
 
130
        
 
131
        dialog = BranchDialog(vfs_file.get_name())
 
132
        dialog.display()
131
133
 
132
134
    def commit_cb(self, menu, vfs_file=None):
133
135
        # We can only cope with local files
140
142
        except NotBranchError:
141
143
            return
142
144
 
143
 
        from bzrlib.plugins.gtk.commit import GCommitDialog
144
 
        dialog = GCommitDialog(tree)
145
 
        dialog.set_title(path + " - Commit")
146
 
        if dialog.run() != gtk.RESPONSE_CANCEL:
147
 
            Commit().commit(working_tree=wt,message=dialog.message,
148
 
                            specific_files=dialog.specific_files)
 
145
        from bzrlib.plugins.gtk.commit import CommitDialog
 
146
        dialog = CommitDialog(tree, path)
 
147
        dialog.display()
 
148
        gtk.main()
149
149
 
150
150
    def log_cb(self, menu, vfs_file):
151
151
        # We can only cope with local files
165
165
 
166
166
        return
167
167
 
 
168
    def pull_cb(self, menu, vfs_file):
 
169
        # We can only cope with local files
 
170
        if vfs_file.get_uri_scheme() != 'file':
 
171
            return
 
172
 
 
173
        file = vfs_file.get_uri()
 
174
 
 
175
        # We only want to continue here if we get a NotBranchError
 
176
        try:
 
177
            tree, path = WorkingTree.open_containing(file)
 
178
        except NotBranchError:
 
179
            return
 
180
 
 
181
        from bzrlib.plugins.gtk.pull import PullDialog
 
182
        dialog = PullDialog(tree, path)
 
183
        dialog.display()
 
184
        gtk.main()
 
185
 
 
186
    def merge_cb(self, menu, vfs_file):
 
187
        # We can only cope with local files
 
188
        if vfs_file.get_uri_scheme() != 'file':
 
189
            return
 
190
 
 
191
        file = vfs_file.get_uri()
 
192
 
 
193
        # We only want to continue here if we get a NotBranchError
 
194
        try:
 
195
            tree, path = WorkingTree.open_containing(file)
 
196
        except NotBranchError:
 
197
            return
 
198
 
 
199
        from bzrlib.plugins.gtk.merge import MergeDialog
 
200
        dialog = MergeDialog(tree, path)
 
201
        dialog.display()
 
202
        gtk.main()
 
203
 
168
204
    def get_background_items(self, window, vfs_file):
 
205
        items = []
169
206
        file = vfs_file.get_uri()
170
207
        try:
171
208
            tree, path = WorkingTree.open_containing(file)
172
209
        except NotBranchError:
173
210
            item = nautilus.MenuItem('BzrNautilus::newtree',
174
 
                                 'Create new Bazaar tree',
 
211
                                 'Make directory versioned',
175
212
                                 'Create new Bazaar tree in this folder')
176
213
            item.connect('activate', self.newtree_cb, vfs_file)
177
214
            items.append(item)
178
215
 
179
216
            item = nautilus.MenuItem('BzrNautilus::clone',
180
 
                                 'Checkout',
 
217
                                 'Checkout Bazaar branch',
181
218
                                 'Checkout Existing Bazaar Branch')
182
219
            item.connect('activate', self.clone_cb, vfs_file)
183
220
            items.append(item)
184
221
 
185
222
            return items
186
223
 
187
 
        items = []
188
224
        item = nautilus.MenuItem('BzrNautilus::log',
189
225
                             'Log',
190
226
                             'Show Bazaar history')
191
227
        item.connect('activate', self.log_cb, vfs_file)
192
228
        items.append(item)
193
229
 
 
230
        item = nautilus.MenuItem('BzrNautilus::pull',
 
231
                             'Pull',
 
232
                             'Pull from another branch')
 
233
        item.connect('activate', self.pull_cb, vfs_file)
 
234
        items.append(item)
 
235
 
 
236
        item = nautilus.MenuItem('BzrNautilus::merge',
 
237
                             'Merge',
 
238
                             'Merge from another branch')
 
239
        item.connect('activate', self.merge_cb, vfs_file)
 
240
        items.append(item)
 
241
 
194
242
        item = nautilus.MenuItem('BzrNautilus::commit',
195
243
                             'Commit',
196
244
                             'Commit Changes')
215
263
                if not vfs_file.is_directory():
216
264
                    return
217
265
                item = nautilus.MenuItem('BzrNautilus::newtree',
218
 
                                     'Create new Bazaar tree',
 
266
                                     'Make directory versioned',
219
267
                                     'Create new Bazaar tree in %s' % vfs_file.get_name())
220
268
                item.connect('activate', self.newtree_cb, vfs_file)
221
269
                return item,
272
320
                items.append(item)
273
321
 
274
322
        return items
 
323
 
 
324
    def get_columns(self):
 
325
        return nautilus.Column("BzrNautilus::bzr_status",
 
326
                               "bzr_status",
 
327
                               "Bzr Status",
 
328
                               "Version control status"),
 
329
 
 
330
    def update_file_info(self, file):
 
331
        if file.get_uri_scheme() != 'file':
 
332
            return
 
333
        
 
334
        try:
 
335
            tree, path = WorkingTree.open_containing(file.get_uri())
 
336
        except NotBranchError:
 
337
            return
 
338
 
 
339
        emblem = None
 
340
        status = None
 
341
 
 
342
        if tree.has_filename(path):
 
343
            emblem = 'cvs-controlled'
 
344
            status = 'unchanged'
 
345
            id = tree.path2id(path)
 
346
 
 
347
            delta = tree.changes_from(tree.branch.basis_tree())
 
348
            if delta.touches_file_id(id):
 
349
                emblem = 'cvs-modified'
 
350
                status = 'modified'
 
351
            for f, _, _ in delta.added:
 
352
                if f == path:
 
353
                    emblem = 'cvs-added'
 
354
                    status = 'added'
 
355
 
 
356
            for of, f, _, _, _, _ in delta.renamed:
 
357
                if f == path:
 
358
                    status = 'renamed from %s' % f
 
359
 
 
360
        elif tree.branch.basis_tree().has_filename(path):
 
361
            emblem = 'cvs-removed'
 
362
            status = 'removed'
 
363
        else:
 
364
            # FIXME: Check for ignored files
 
365
            status = 'unversioned'
 
366
        
 
367
        if emblem is not None:
 
368
            file.add_emblem(emblem)
 
369
        file.add_string_attribute('bzr_status', status)