/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: 2006-10-03 17:09:52 UTC
  • Revision ID: jelmer@samba.org-20061003170952-64f50c3b64526aac
Show column with file status.
Add emblems indicating bzr status to files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
from bzrlib.bzrdir import BzrDir
4
4
from bzrlib.errors import NotBranchError
5
5
from bzrlib.workingtree import WorkingTree
 
6
from bzrlib.tree import file_status
6
7
 
7
8
from bzrlib.plugin import load_plugins
8
9
load_plugins()
9
10
 
10
11
from bzrlib.plugins.gtk import cmd_visualise, cmd_gannotate
11
12
 
12
 
class BzrExtension(nautilus.MenuProvider):
 
13
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider):
13
14
    def __init__(self):
14
15
        pass
15
16
 
272
273
                items.append(item)
273
274
 
274
275
        return items
 
276
 
 
277
    def get_columns(self):
 
278
        return nautilus.Column("BzrNautilus::bzr_status",
 
279
                               "bzr_status",
 
280
                               "Bzr Status",
 
281
                               "Version control status"),
 
282
 
 
283
    def update_file_info(self, file):
 
284
        if file.get_uri_scheme() != 'file':
 
285
            return
 
286
        
 
287
        try:
 
288
            tree, path = WorkingTree.open_containing(file.get_uri())
 
289
        except NotBranchError:
 
290
            return
 
291
 
 
292
        emblem = None
 
293
        status = None
 
294
 
 
295
        if tree.has_filename(path):
 
296
            emblem = 'cvs-controlled'
 
297
            status = 'unchanged'
 
298
            id = tree.path2id(path)
 
299
 
 
300
            delta = tree.changes_from(tree.branch.basis_tree())
 
301
            if delta.touches_file_id(id):
 
302
                emblem = 'cvs-modified'
 
303
                status = 'modified'
 
304
            for f, _, _ in delta.added:
 
305
                if f == path:
 
306
                    emblem = 'cvs-added'
 
307
                    status = 'added'
 
308
 
 
309
            for of, f, _, _, _, _ in delta.renamed:
 
310
                if f == path:
 
311
                    status = 'renamed from %s' % f
 
312
 
 
313
        elif tree.branch.basis_tree().has_filename(path):
 
314
            emblem = 'cvs-removed'
 
315
            status = 'removed'
 
316
        else:
 
317
            # FIXME: Check for ignored files
 
318
            status = 'unversioned'
 
319
        
 
320
        if emblem is not None:
 
321
            file.add_emblem(emblem)
 
322
        file.add_string_attribute('bzr_status', status)