/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

Merged with mainline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#
3
3
# Copyright (C) 2006 Jeff Bailey
4
4
# Copyright (C) 2006 Wouter van Heyst
5
 
# Copyright (C) 2006 Jelmer Vernooij
 
5
# Copyright (C) 2006-2008 Jelmer Vernooij <jelmer@samba.org>
6
6
#
7
7
# Published under the GNU GPL
8
8
 
9
9
import gtk
10
10
import nautilus
11
11
import bzrlib
 
12
from bzrlib.branch import Branch
12
13
from bzrlib.bzrdir import BzrDir
13
 
from bzrlib.errors import NotBranchError
14
 
from bzrlib.errors import NoWorkingTree
15
 
from bzrlib.errors import UnsupportedProtocol
 
14
from bzrlib.errors import NotBranchError, NoWorkingTree, UnsupportedProtocol
 
15
from bzrlib.tree import file_status
16
16
from bzrlib.workingtree import WorkingTree
17
 
from bzrlib.branch import Branch
18
 
from bzrlib.tree import file_status
19
17
 
20
18
from bzrlib.plugin import load_plugins
21
19
load_plugins()
160
158
                path = e.path
161
159
 
162
160
        from bzrlib.plugins.gtk.commit import CommitDialog
163
 
        dialog = CommitDialog(tree, path, not branch)
 
161
        dialog = CommitDialog(tree, path)
164
162
        response = dialog.run()
165
163
        if response != gtk.RESPONSE_NONE:
166
164
            dialog.hide()
241
239
            items.append(item)
242
240
 
243
241
            return items
 
242
        except NoWorkingTree:
 
243
            return
244
244
 
245
245
        item = nautilus.MenuItem('BzrNautilus::log',
246
246
                             'Log',
268
268
 
269
269
        return items
270
270
 
271
 
 
272
271
    def get_file_items(self, window, files):
273
272
        items = []
274
273
 
276
275
        for vfs_file in files:
277
276
            # We can only cope with local files
278
277
            if vfs_file.get_uri_scheme() != 'file':
279
 
                return
 
278
                continue
280
279
 
281
280
            file = vfs_file.get_uri()
282
281
            try:
283
282
                tree, path = WorkingTree.open_containing(file)
284
283
            except NotBranchError:
285
284
                if not vfs_file.is_directory():
286
 
                    return
 
285
                    continue
287
286
                item = nautilus.MenuItem('BzrNautilus::newtree',
288
287
                                     'Make directory versioned',
289
288
                                     'Create new Bazaar tree in %s' % vfs_file.get_name())
290
289
                item.connect('activate', self.newtree_cb, vfs_file)
291
290
                return item,
 
291
            except NoWorkingTree:
 
292
                continue
292
293
            # Refresh the list of filestatuses in the working tree
293
294
            if path not in wtfiles.keys():
294
295
                tree.lock_read()
362
363
            tree, path = WorkingTree.open_containing(file.get_uri())
363
364
        except NotBranchError:
364
365
            return
 
366
        except NoWorkingTree:
 
367
            return
365
368
 
366
369
        emblem = None
367
370
        status = None
368
371
 
369
372
        if tree.has_filename(path):
370
 
            emblem = 'cvs-controlled'
 
373
            emblem = 'bzr-controlled'
371
374
            status = 'unchanged'
372
375
            id = tree.path2id(path)
373
376
 
374
377
            delta = tree.changes_from(tree.branch.basis_tree())
375
378
            if delta.touches_file_id(id):
376
 
                emblem = 'cvs-modified'
 
379
                emblem = 'bzr-modified'
377
380
                status = 'modified'
378
381
            for f, _, _ in delta.added:
379
382
                if f == path:
380
 
                    emblem = 'cvs-added'
 
383
                    emblem = 'bzr-added'
381
384
                    status = 'added'
382
385
 
383
386
            for of, f, _, _, _, _ in delta.renamed:
385
388
                    status = 'renamed from %s' % f
386
389
 
387
390
        elif tree.branch.basis_tree().has_filename(path):
388
 
            emblem = 'cvs-removed'
 
391
            emblem = 'bzr-removed'
389
392
            status = 'removed'
390
393
        else:
391
394
            # FIXME: Check for ignored files
392
395
            status = 'unversioned'
 
396
            emblem = 'bzr-unversioned'
393
397
        
394
398
        if emblem is not None:
395
399
            file.add_emblem(emblem)