/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-09-30 10:21:43 UTC
  • Revision ID: jelmer@samba.org-20060930102143-c0ef64d6ca860c21
Merge some files from Olive and bzr-gtk.

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
7
6
 
8
7
from bzrlib.plugin import load_plugins
9
8
load_plugins()
10
9
 
11
10
from bzrlib.plugins.gtk import cmd_visualise, cmd_gannotate
12
11
 
13
 
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider):
 
12
class BzrExtension(nautilus.MenuProvider):
14
13
    def __init__(self):
15
14
        pass
16
15
 
70
69
        except NotBranchError:
71
70
            return
72
71
 
73
 
        from bzrlib.plugins.gtk.viz.diff import DiffWindow
 
72
        from bzrlib.plugins.gtk.viz.diffwin import DiffWindow
74
73
        window = DiffWindow()
75
 
        window.set_diff(tree.branch.nick, tree, tree.branch.basis_tree())
 
74
        window.set_diff(tree.branch, tree, tree.branch.revision_tree())
76
75
        window.show()
77
76
 
78
77
        return
118
117
        if vfs_file.get_uri_scheme() != 'file':
119
118
            return
120
119
 
121
 
        from bzrlib.plugins.gtk.branch import BranchDialog
122
 
        
123
 
        dialog = BranchDialog(vfs_file.get_name())
124
 
        dialog.display()
 
120
        file = vfs_file.get_uri()
 
121
        try:
 
122
            tree, path = WorkingTree.open_containing(file)
 
123
        except NotBranchError:
 
124
            return
 
125
 
 
126
        from bzrlib.plugins.gtk.clone import CloneDialog
 
127
        dialog = CloneDialog(file)
 
128
        if dialog.run() != gtk.RESPONSE_CANCEL:
 
129
            bzrdir = BzrDir.open(dialog.url)
 
130
            bzrdir.sprout(dialog.dest_path)
125
131
 
126
132
    def commit_cb(self, menu, vfs_file=None):
127
133
        # We can only cope with local files
134
140
        except NotBranchError:
135
141
            return
136
142
 
137
 
        from bzrlib.plugins.gtk.commit import CommitDialog
138
 
        dialog = CommitDialog(tree, path)
139
 
        dialog.display()
140
 
        gtk.main()
 
143
        from bzrlib.plugins.gtk.commit import GCommitDialog
 
144
        dialog = GCommitDialog(tree)
 
145
        dialog.set_title(path + " - Commit")
 
146
        if dialog.run() != gtk.RESPONSE_CANCEL:
 
147
            Commit().commit(working_tree=wt,message=dialog.message,
 
148
                            specific_files=dialog.specific_files)
141
149
 
142
150
    def log_cb(self, menu, vfs_file):
143
151
        # We can only cope with local files
157
165
 
158
166
        return
159
167
 
160
 
    def pull_cb(self, menu, vfs_file):
161
 
        # We can only cope with local files
162
 
        if vfs_file.get_uri_scheme() != 'file':
163
 
            return
164
 
 
165
 
        file = vfs_file.get_uri()
166
 
 
167
 
        # We only want to continue here if we get a NotBranchError
168
 
        try:
169
 
            tree, path = WorkingTree.open_containing(file)
170
 
        except NotBranchError:
171
 
            return
172
 
 
173
 
        from bzrlib.plugins.gtk.pull import PullDialog
174
 
        dialog = PullDialog(tree, path)
175
 
        dialog.display()
176
 
        gtk.main()
177
 
 
178
 
    def merge_cb(self, menu, vfs_file):
179
 
        # We can only cope with local files
180
 
        if vfs_file.get_uri_scheme() != 'file':
181
 
            return
182
 
 
183
 
        file = vfs_file.get_uri()
184
 
 
185
 
        # We only want to continue here if we get a NotBranchError
186
 
        try:
187
 
            tree, path = WorkingTree.open_containing(file)
188
 
        except NotBranchError:
189
 
            return
190
 
 
191
 
        from bzrlib.plugins.gtk.merge import MergeDialog
192
 
        dialog = MergeDialog(tree, path)
193
 
        dialog.display()
194
 
        gtk.main()
195
 
 
196
168
    def get_background_items(self, window, vfs_file):
197
 
        items = []
198
169
        file = vfs_file.get_uri()
199
170
        try:
200
171
            tree, path = WorkingTree.open_containing(file)
201
172
        except NotBranchError:
202
173
            item = nautilus.MenuItem('BzrNautilus::newtree',
203
 
                                 'Make directory versioned',
 
174
                                 'Create new Bazaar tree',
204
175
                                 'Create new Bazaar tree in this folder')
205
176
            item.connect('activate', self.newtree_cb, vfs_file)
206
177
            items.append(item)
207
178
 
208
179
            item = nautilus.MenuItem('BzrNautilus::clone',
209
 
                                 'Checkout Bazaar branch',
 
180
                                 'Checkout',
210
181
                                 'Checkout Existing Bazaar Branch')
211
182
            item.connect('activate', self.clone_cb, vfs_file)
212
183
            items.append(item)
213
184
 
214
185
            return items
215
186
 
 
187
        items = []
216
188
        item = nautilus.MenuItem('BzrNautilus::log',
217
189
                             'Log',
218
190
                             'Show Bazaar history')
219
191
        item.connect('activate', self.log_cb, vfs_file)
220
192
        items.append(item)
221
193
 
222
 
        item = nautilus.MenuItem('BzrNautilus::pull',
223
 
                             'Pull',
224
 
                             'Pull from another branch')
225
 
        item.connect('activate', self.pull_cb, vfs_file)
226
 
        items.append(item)
227
 
 
228
 
        item = nautilus.MenuItem('BzrNautilus::merge',
229
 
                             'Merge',
230
 
                             'Merge from another branch')
231
 
        item.connect('activate', self.merge_cb, vfs_file)
232
 
        items.append(item)
233
 
 
234
194
        item = nautilus.MenuItem('BzrNautilus::commit',
235
195
                             'Commit',
236
196
                             'Commit Changes')
255
215
                if not vfs_file.is_directory():
256
216
                    return
257
217
                item = nautilus.MenuItem('BzrNautilus::newtree',
258
 
                                     'Make directory versioned',
 
218
                                     'Create new Bazaar tree',
259
219
                                     'Create new Bazaar tree in %s' % vfs_file.get_name())
260
220
                item.connect('activate', self.newtree_cb, vfs_file)
261
221
                return item,
312
272
                items.append(item)
313
273
 
314
274
        return items
315
 
 
316
 
    def get_columns(self):
317
 
        return nautilus.Column("BzrNautilus::bzr_status",
318
 
                               "bzr_status",
319
 
                               "Bzr Status",
320
 
                               "Version control status"),
321
 
 
322
 
    def update_file_info(self, file):
323
 
        if file.get_uri_scheme() != 'file':
324
 
            return
325
 
        
326
 
        try:
327
 
            tree, path = WorkingTree.open_containing(file.get_uri())
328
 
        except NotBranchError:
329
 
            return
330
 
 
331
 
        emblem = None
332
 
        status = None
333
 
 
334
 
        if tree.has_filename(path):
335
 
            emblem = 'cvs-controlled'
336
 
            status = 'unchanged'
337
 
            id = tree.path2id(path)
338
 
 
339
 
            delta = tree.changes_from(tree.branch.basis_tree())
340
 
            if delta.touches_file_id(id):
341
 
                emblem = 'cvs-modified'
342
 
                status = 'modified'
343
 
            for f, _, _ in delta.added:
344
 
                if f == path:
345
 
                    emblem = 'cvs-added'
346
 
                    status = 'added'
347
 
 
348
 
            for of, f, _, _, _, _ in delta.renamed:
349
 
                if f == path:
350
 
                    status = 'renamed from %s' % f
351
 
 
352
 
        elif tree.branch.basis_tree().has_filename(path):
353
 
            emblem = 'cvs-removed'
354
 
            status = 'removed'
355
 
        else:
356
 
            # FIXME: Check for ignored files
357
 
            status = 'unversioned'
358
 
        
359
 
        if emblem is not None:
360
 
            file.add_emblem(emblem)
361
 
        file.add_string_attribute('bzr_status', status)