~dasch/bzr-gtk/tooltips

« back to all changes in this revision

Viewing changes to nautilus-bzr.py

  • Committer: Szilveszter Farkas
  • Date: 2007-12-20 19:50:25 UTC
  • Revision ID: szilveszter@macbookpro.local-20071220195025-to6mz7bgwl56is0k
Applied nautilus-bzr patches by Toshio Kuratomi.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
#
7
7
# Published under the GNU GPL
8
8
 
 
9
import gtk
9
10
import nautilus
10
11
import bzrlib
11
12
from bzrlib.bzrdir import BzrDir
12
13
from bzrlib.errors import NotBranchError
 
14
from bzrlib.errors import NoWorkingTree
 
15
from bzrlib.errors import UnsupportedProtocol
13
16
from bzrlib.workingtree import WorkingTree
 
17
from bzrlib.branch import Branch
14
18
from bzrlib.tree import file_status
15
19
 
16
20
from bzrlib.plugin import load_plugins
78
82
        except NotBranchError:
79
83
            return
80
84
 
81
 
        from bzrlib.plugins.gtk.viz.diff import DiffWindow
 
85
        from bzrlib.plugins.gtk.diff import DiffWindow
82
86
        window = DiffWindow()
83
87
        window.set_diff(tree.branch.nick, tree, tree.branch.basis_tree())
84
88
        window.show()
96
100
        try:
97
101
            tree, path = WorkingTree.open_containing(file)
98
102
        except NotBranchError:
99
 
            BzrDir.create_branch_and_repo(file)
 
103
            BzrDir.create_standalone_workingtree(file)
100
104
 
101
105
    def remove_cb(self, menu, vfs_file):
102
106
        # We can only cope with local files
129
133
        from bzrlib.plugins.gtk.branch import BranchDialog
130
134
        
131
135
        dialog = BranchDialog(vfs_file.get_name())
132
 
        dialog.display()
 
136
        response = dialog.run()
 
137
        if response != gtk.RESPONSE_NONE:
 
138
            dialog.hide()
 
139
            dialog.destroy()
133
140
 
134
141
    def commit_cb(self, menu, vfs_file=None):
135
142
        # We can only cope with local files
137
144
            return
138
145
 
139
146
        file = vfs_file.get_uri()
 
147
        tree = None
 
148
        branch = None
140
149
        try:
141
150
            tree, path = WorkingTree.open_containing(file)
142
 
        except NotBranchError:
143
 
            return
 
151
            branch = tree.branch
 
152
        except NotBranchError, e:
 
153
            path = e.path
 
154
            #return
 
155
        except NoWorkingTree, e:
 
156
            path = e.base
 
157
            try:
 
158
                (branch, path) = Branch.open_containing(path)
 
159
            except NotBranchError, e:
 
160
                path = e.path
144
161
 
145
162
        from bzrlib.plugins.gtk.commit import CommitDialog
146
 
        dialog = CommitDialog(tree, path)
147
 
        dialog.display()
148
 
        gtk.main()
 
163
        dialog = CommitDialog(tree, path, not branch)
 
164
        response = dialog.run()
 
165
        if response != gtk.RESPONSE_NONE:
 
166
            dialog.hide()
 
167
            dialog.destroy()
149
168
 
150
169
    def log_cb(self, menu, vfs_file):
151
170
        # We can only cope with local files
206
225
        file = vfs_file.get_uri()
207
226
        try:
208
227
            tree, path = WorkingTree.open_containing(file)
 
228
        except UnsupportedProtocol:
 
229
            return
209
230
        except NotBranchError:
210
231
            item = nautilus.MenuItem('BzrNautilus::newtree',
211
232
                                 'Make directory versioned',
251
272
    def get_file_items(self, window, files):
252
273
        items = []
253
274
 
 
275
        wtfiles = {}
254
276
        for vfs_file in files:
255
277
            # We can only cope with local files
256
278
            if vfs_file.get_uri_scheme() != 'file':
267
289
                                     'Create new Bazaar tree in %s' % vfs_file.get_name())
268
290
                item.connect('activate', self.newtree_cb, vfs_file)
269
291
                return item,
270
 
 
271
 
            file_class = tree.file_class(path)
272
 
 
273
 
            if file_class == '?':
 
292
            # Refresh the list of filestatuses in the working tree
 
293
            if path not in wtfiles.keys():
 
294
                tree.lock_read()
 
295
                for rpath, file_class, kind, id, entry in tree.list_files():
 
296
                    wtfiles[rpath] = file_class
 
297
                tree.unlock()
 
298
                wtfiles[u''] = 'V'
 
299
 
 
300
            if wtfiles[path] == '?':
274
301
                item = nautilus.MenuItem('BzrNautilus::add',
275
302
                                     'Add',
276
303
                                     'Add as versioned file')
282
309
                                     'Ignore file for versioning')
283
310
                item.connect('activate', self.ignore_cb, vfs_file)
284
311
                items.append(item)
285
 
            elif file_class == 'I':
 
312
            elif wtfiles[path] == 'I':
286
313
                item = nautilus.MenuItem('BzrNautilus::unignore',
287
314
                                     'Unignore',
288
315
                                     'Unignore file for versioning')
289
316
                item.connect('activate', self.unignore_cb, vfs_file)
290
317
                items.append(item)
291
 
            elif file_class == 'V':
 
318
            elif wtfiles[path] == 'V':
292
319
                item = nautilus.MenuItem('BzrNautilus::log',
293
320
                                 'Log',
294
321
                                 'List changes')