/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: 2007-07-15 18:12:57 UTC
  • Revision ID: jelmer@samba.org-20070715181257-g264qus2zyi3v39z
Add RevisionSelectionBox widget, use in TagDialog.

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