/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: Jelmer Vernooij
  • Date: 2011-04-02 12:42:35 UTC
  • Revision ID: jelmer@samba.org-20110402124235-h9cvzbawsk79fol3
RemoveĀ unusedĀ import.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
import gtk
10
10
import nautilus
11
 
import bzrlib
12
11
from bzrlib.branch import Branch
13
12
from bzrlib.bzrdir import BzrDir
14
 
from bzrlib.errors import NotBranchError, NoWorkingTree, UnsupportedProtocol
15
 
from bzrlib.tree import file_status
 
13
from bzrlib.errors import (
 
14
    NotBranchError,
 
15
    NoWorkingTree,
 
16
    UnsupportedProtocol,
 
17
    )
16
18
from bzrlib.workingtree import WorkingTree
17
19
from bzrlib.config import GlobalConfig
18
20
 
19
21
from bzrlib.plugin import load_plugins
20
22
load_plugins()
21
23
 
22
 
from bzrlib.plugins.gtk import _i18n, cmd_visualise, cmd_gannotate
 
24
from bzrlib.plugins.gtk.commands import (
 
25
    cmd_gannotate,
 
26
    start_viz_window,
 
27
    )
 
28
 
 
29
print "Bazaar nautilus module initialized"
 
30
 
23
31
 
24
32
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider):
 
33
 
25
34
    def __init__(self):
26
35
        pass
27
36
 
83
92
 
84
93
        from bzrlib.plugins.gtk.diff import DiffWindow
85
94
        window = DiffWindow()
86
 
        window.set_diff(tree.branch.nick, tree, tree.branch.basis_tree())
 
95
        window.set_diff(tree.branch._get_nick(local=True), tree, 
 
96
                        tree.branch.basis_tree())
87
97
        window.show()
88
98
 
89
99
        return
174
184
 
175
185
        # We only want to continue here if we get a NotBranchError
176
186
        try:
177
 
            tree, path = WorkingTree.open_containing(file)
 
187
            branch, path = Branch.open_containing(file)
178
188
        except NotBranchError:
179
189
            return
180
190
 
181
 
        vis = cmd_visualise()
182
 
        vis.run(file)
183
 
 
184
 
        return
 
191
        pp = start_viz_window(branch, [branch.last_revision()])
 
192
        pp.show()
 
193
        gtk.main()
185
194
 
186
195
    def pull_cb(self, menu, vfs_file):
187
196
        # We can only cope with local files
216
225
 
217
226
        from bzrlib.plugins.gtk.merge import MergeDialog
218
227
        dialog = MergeDialog(tree, path)
219
 
        dialog.display()
220
 
        gtk.main()
 
228
        dialog.run()
 
229
        dialog.destroy()
221
230
 
222
231
    def get_background_items(self, window, vfs_file):
223
232
        items = []
237
246
            items.append(item)
238
247
 
239
248
            item = nautilus.MenuItem('BzrNautilus::clone',
240
 
                                 'Checkout Bazaar branch',
 
249
                                 'Checkout Bazaar branch ...',
241
250
                                 'Checkout Existing Bazaar Branch')
242
251
            item.connect('activate', self.clone_cb, vfs_file)
243
252
            items.append(item)
254
263
            return item,
255
264
        else:
256
265
            item = nautilus.MenuItem('BzrNautilus::disable',
257
 
                                      'Disable Bazaar Plugin for the Branch',
 
266
                                      'Disable Bazaar Plugin this Branch',
258
267
                                      'Disable Bazaar plugin for nautilus')
259
268
            item.connect('activate', self.toggle_integration, 'False', vfs_file)
260
269
            items.append(item)
261
270
 
262
271
        item = nautilus.MenuItem('BzrNautilus::log',
263
 
                             'Log',
 
272
                             'History ...',
264
273
                             'Show Bazaar history')
265
274
        item.connect('activate', self.log_cb, vfs_file)
266
275
        items.append(item)
267
276
 
268
277
        item = nautilus.MenuItem('BzrNautilus::pull',
269
 
                             'Pull',
 
278
                             'Pull ...',
270
279
                             'Pull from another branch')
271
280
        item.connect('activate', self.pull_cb, vfs_file)
272
281
        items.append(item)
273
282
 
274
283
        item = nautilus.MenuItem('BzrNautilus::merge',
275
 
                             'Merge',
 
284
                             'Merge ...',
276
285
                             'Merge from another branch')
277
286
        item.connect('activate', self.merge_cb, vfs_file)
278
287
        items.append(item)
279
288
 
280
289
        item = nautilus.MenuItem('BzrNautilus::commit',
281
 
                             'Commit',
 
290
                             'Commit ...',
282
291
                             'Commit Changes')
283
292
        item.connect('activate', self.commit_cb, vfs_file)
284
293
        items.append(item)
341
350
                items.append(item)
342
351
            elif wtfiles[path] == 'V':
343
352
                item = nautilus.MenuItem('BzrNautilus::log',
344
 
                                 'Log',
 
353
                                 'History ...',
345
354
                                 'List changes')
346
355
                item.connect('activate', self.log_cb, vfs_file)
347
356
                items.append(item)
348
357
 
349
358
                item = nautilus.MenuItem('BzrNautilus::diff',
350
 
                                 'Diff',
 
359
                                 'View Changes ...',
351
360
                                 'Show differences')
352
361
                item.connect('activate', self.diff_cb, vfs_file)
353
362
                items.append(item)
359
368
                items.append(item)
360
369
 
361
370
                item = nautilus.MenuItem('BzrNautilus::annotate',
362
 
                             'Annotate',
 
371
                             'Annotate ...',
363
372
                             'Annotate File Data')
364
373
                item.connect('activate', self.annotate_cb, vfs_file)
365
374
                items.append(item)
366
375
 
367
376
                item = nautilus.MenuItem('BzrNautilus::commit',
368
 
                             'Commit',
 
377
                             'Commit ...',
369
378
                             'Commit Changes')
370
379
                item.connect('activate', self.commit_cb, vfs_file)
371
380
                items.append(item)
397
406
        emblem = None
398
407
        status = None
399
408
 
400
 
        if tree.has_filename(path):
 
409
        id = tree.path2id(path)
 
410
        if id == None:
 
411
            if tree.is_ignored(path):
 
412
                status = 'ignored'
 
413
                emblem = 'bzr-ignored'
 
414
            else:
 
415
                status = 'unversioned'
 
416
                        
 
417
        elif tree.has_filename(path):
401
418
            emblem = 'bzr-controlled'
402
419
            status = 'unchanged'
403
 
            id = tree.path2id(path)
404
420
 
405
421
            delta = tree.changes_from(tree.branch.basis_tree())
406
422
            if delta.touches_file_id(id):