/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: 2008-01-13 14:15:20 UTC
  • mto: (423.1.2 trunk)
  • mto: This revision was merged to the branch mainline in revision 429.
  • Revision ID: daniel.schierbeck@gmail.com-20080113141520-ol1on2ju8h833rh0
Moved the branch window class to the viz package.

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