/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: 2008-03-14 02:19:21 UTC
  • mto: (452.2.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 453.
  • Revision ID: jelmer@samba.org-20080314021921-2dgptk62dhp7pd91
Honor child_submit_to in the submit_branch if no email address was specified.
Consistent with the changes in bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
from bzrlib.errors import NotBranchError, NoWorkingTree, UnsupportedProtocol
15
15
from bzrlib.tree import file_status
16
16
from bzrlib.workingtree import WorkingTree
17
 
from bzrlib.config import GlobalConfig
18
17
 
19
18
from bzrlib.plugin import load_plugins
20
19
load_plugins()
21
20
 
22
 
from bzrlib.plugins.gtk import _i18n
23
 
from bzrlib.plugins.gtk.commands import cmd_gannotate, start_viz_window
24
 
 
25
 
print "Bazaar nautilus module initialized"
26
 
 
 
21
from bzrlib.plugins.gtk import cmd_visualise, cmd_gannotate
27
22
 
28
23
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider):
29
24
    def __init__(self):
87
82
 
88
83
        from bzrlib.plugins.gtk.diff import DiffWindow
89
84
        window = DiffWindow()
90
 
        window.set_diff(tree.branch._get_nick(local=True), tree, 
91
 
                        tree.branch.basis_tree())
 
85
        window.set_diff(tree.branch.nick, tree, tree.branch.basis_tree())
92
86
        window.show()
93
87
 
94
88
        return
179
173
 
180
174
        # We only want to continue here if we get a NotBranchError
181
175
        try:
182
 
            branch, path = Branch.open_containing(file)
 
176
            tree, path = WorkingTree.open_containing(file)
183
177
        except NotBranchError:
184
178
            return
185
179
 
186
 
        pp = start_viz_window(branch, [branch.last_revision()])
187
 
        pp.show()
188
 
        gtk.main()
 
180
        vis = cmd_visualise()
 
181
        vis.run(file)
 
182
 
 
183
        return
189
184
 
190
185
    def pull_cb(self, menu, vfs_file):
191
186
        # We can only cope with local files
220
215
 
221
216
        from bzrlib.plugins.gtk.merge import MergeDialog
222
217
        dialog = MergeDialog(tree, path)
223
 
        dialog.run()
224
 
        dialog.destroy()
 
218
        dialog.display()
 
219
        gtk.main()
225
220
 
226
221
    def get_background_items(self, window, vfs_file):
227
222
        items = []
228
223
        file = vfs_file.get_uri()
229
 
 
230
224
        try:
231
225
            tree, path = WorkingTree.open_containing(file)
232
 
            disabled_flag = self.check_branch_enabled(tree.branch)
233
226
        except UnsupportedProtocol:
234
227
            return
235
228
        except NotBranchError:
236
 
            disabled_flag = self.check_branch_enabled()
237
229
            item = nautilus.MenuItem('BzrNautilus::newtree',
238
230
                                 'Make directory versioned',
239
231
                                 'Create new Bazaar tree in this folder')
241
233
            items.append(item)
242
234
 
243
235
            item = nautilus.MenuItem('BzrNautilus::clone',
244
 
                                 'Checkout Bazaar branch ...',
 
236
                                 'Checkout Bazaar branch',
245
237
                                 'Checkout Existing Bazaar Branch')
246
238
            item.connect('activate', self.clone_cb, vfs_file)
247
239
            items.append(item)
249
241
            return items
250
242
        except NoWorkingTree:
251
243
            return
252
 
        
253
 
        if disabled_flag == 'False':
254
 
            item = nautilus.MenuItem('BzrNautilus::enable',
255
 
                                     'Enable Bazaar Plugin for this Branch',
256
 
                                     'Enable Bazaar plugin for nautilus')
257
 
            item.connect('activate', self.toggle_integration, 'True', vfs_file)
258
 
            return item,
259
 
        else:
260
 
            item = nautilus.MenuItem('BzrNautilus::disable',
261
 
                                      'Disable Bazaar Plugin this Branch',
262
 
                                      'Disable Bazaar plugin for nautilus')
263
 
            item.connect('activate', self.toggle_integration, 'False', vfs_file)
264
 
            items.append(item)
265
244
 
266
245
        item = nautilus.MenuItem('BzrNautilus::log',
267
 
                             'History ...',
 
246
                             'Log',
268
247
                             'Show Bazaar history')
269
248
        item.connect('activate', self.log_cb, vfs_file)
270
249
        items.append(item)
271
250
 
272
251
        item = nautilus.MenuItem('BzrNautilus::pull',
273
 
                             'Pull ...',
 
252
                             'Pull',
274
253
                             'Pull from another branch')
275
254
        item.connect('activate', self.pull_cb, vfs_file)
276
255
        items.append(item)
277
256
 
278
257
        item = nautilus.MenuItem('BzrNautilus::merge',
279
 
                             'Merge ...',
 
258
                             'Merge',
280
259
                             'Merge from another branch')
281
260
        item.connect('activate', self.merge_cb, vfs_file)
282
261
        items.append(item)
283
262
 
284
263
        item = nautilus.MenuItem('BzrNautilus::commit',
285
 
                             'Commit ...',
 
264
                             'Commit',
286
265
                             'Commit Changes')
287
266
        item.connect('activate', self.commit_cb, vfs_file)
288
267
        items.append(item)
291
270
 
292
271
    def get_file_items(self, window, files):
293
272
        items = []
294
 
        
 
273
 
295
274
        wtfiles = {}
296
275
        for vfs_file in files:
297
276
            # We can only cope with local files
301
280
            file = vfs_file.get_uri()
302
281
            try:
303
282
                tree, path = WorkingTree.open_containing(file)
304
 
                disabled_flag = self.check_branch_enabled(tree.branch)
305
283
            except NotBranchError:
306
 
                disabled_flag = self.check_branch_enabled()
307
284
                if not vfs_file.is_directory():
308
285
                    continue
309
 
 
310
 
                if disabled_flag == 'False':
311
 
                    return
312
 
 
313
286
                item = nautilus.MenuItem('BzrNautilus::newtree',
314
287
                                     'Make directory versioned',
315
288
                                     'Create new Bazaar tree in %s' % vfs_file.get_name())
345
318
                items.append(item)
346
319
            elif wtfiles[path] == 'V':
347
320
                item = nautilus.MenuItem('BzrNautilus::log',
348
 
                                 'History ...',
 
321
                                 'Log',
349
322
                                 'List changes')
350
323
                item.connect('activate', self.log_cb, vfs_file)
351
324
                items.append(item)
352
325
 
353
326
                item = nautilus.MenuItem('BzrNautilus::diff',
354
 
                                 'View Changes ...',
 
327
                                 'Diff',
355
328
                                 'Show differences')
356
329
                item.connect('activate', self.diff_cb, vfs_file)
357
330
                items.append(item)
363
336
                items.append(item)
364
337
 
365
338
                item = nautilus.MenuItem('BzrNautilus::annotate',
366
 
                             'Annotate ...',
 
339
                             'Annotate',
367
340
                             'Annotate File Data')
368
341
                item.connect('activate', self.annotate_cb, vfs_file)
369
342
                items.append(item)
370
343
 
371
344
                item = nautilus.MenuItem('BzrNautilus::commit',
372
 
                             'Commit ...',
 
345
                             'Commit',
373
346
                             'Commit Changes')
374
347
                item.connect('activate', self.commit_cb, vfs_file)
375
348
                items.append(item)
383
356
                               "Version control status"),
384
357
 
385
358
    def update_file_info(self, file):
386
 
 
387
359
        if file.get_uri_scheme() != 'file':
388
360
            return
389
361
        
392
364
        except NotBranchError:
393
365
            return
394
366
        except NoWorkingTree:
395
 
            return   
396
 
 
397
 
        disabled_flag = self.check_branch_enabled(tree.branch)
398
 
        if disabled_flag == 'False':
399
367
            return
400
368
 
401
369
        emblem = None
402
370
        status = None
403
371
 
404
 
        id = tree.path2id(path)
405
 
        if id == None:
406
 
            if tree.is_ignored(path):
407
 
                status = 'ignored'
408
 
                emblem = 'bzr-ignored'
409
 
            else:
410
 
                status = 'unversioned'
411
 
                        
412
 
        elif tree.has_filename(path):
 
372
        if tree.has_filename(path):
413
373
            emblem = 'bzr-controlled'
414
374
            status = 'unchanged'
 
375
            id = tree.path2id(path)
415
376
 
416
377
            delta = tree.changes_from(tree.branch.basis_tree())
417
378
            if delta.touches_file_id(id):
432
393
        else:
433
394
            # FIXME: Check for ignored files
434
395
            status = 'unversioned'
 
396
            emblem = 'bzr-unversioned'
435
397
        
436
398
        if emblem is not None:
437
399
            file.add_emblem(emblem)
438
400
        file.add_string_attribute('bzr_status', status)
439
 
 
440
 
    def check_branch_enabled(self, branch=None):
441
 
        # Supports global disable, but there is currently no UI to do this
442
 
        config = GlobalConfig()
443
 
        disabled_flag = config.get_user_option('nautilus_integration')
444
 
        if disabled_flag != 'False':
445
 
            if branch is not None:
446
 
                config = branch.get_config()
447
 
                disabled_flag = config.get_user_option('nautilus_integration')
448
 
        return disabled_flag
449
 
 
450
 
    def toggle_integration(self, menu, action, vfs_file=None):
451
 
        try:
452
 
            tree, path = WorkingTree.open_containing(vfs_file.get_uri())
453
 
        except NotBranchError:
454
 
            return
455
 
        except NoWorkingTree:
456
 
            return
457
 
        branch = tree.branch
458
 
        if branch is None:
459
 
            config = GlobalConfig()
460
 
        else:
461
 
            config = branch.get_config()
462
 
        config.set_user_option('nautilus_integration', action)
463