/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: Aaron Bentley
  • Date: 2006-11-21 14:19:41 UTC
  • mfrom: (91.1.12 trunk)
  • mto: (66.6.5 gtk)
  • mto: This revision was merged to the branch mainline in revision 112.
  • Revision ID: abentley@panoramicfeedback.com-20061121141941-m82u7iqexarwirkv
MergeĀ fromĀ upstream

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
 
71
72
 
72
73
        from bzrlib.plugins.gtk.viz.diffwin import DiffWindow
73
74
        window = DiffWindow()
74
 
        window.set_diff(tree.branch, tree, tree.branch.revision_tree())
 
75
        window.set_diff(tree.branch.nick, tree, tree.branch.basis_tree())
75
76
        window.show()
76
77
 
77
78
        return
117
118
        if vfs_file.get_uri_scheme() != 'file':
118
119
            return
119
120
 
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)
 
121
        from bzrlib.plugins.gtk.olive.branch import BranchDialog
 
122
        
 
123
        dialog = BranchDialog(vfs_file.get_name())
 
124
        dialog.display()
131
125
 
132
126
    def commit_cb(self, menu, vfs_file=None):
133
127
        # We can only cope with local files
140
134
        except NotBranchError:
141
135
            return
142
136
 
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)
 
137
        from bzrlib.plugins.gtk.olive.commit import CommitDialog
 
138
        dialog = CommitDialog(tree, path)
 
139
        dialog.display()
 
140
        gtk.main()
149
141
 
150
142
    def log_cb(self, menu, vfs_file):
151
143
        # We can only cope with local files
165
157
 
166
158
        return
167
159
 
 
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.olive.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.olive.merge import MergeDialog
 
192
        dialog = MergeDialog(tree, path)
 
193
        dialog.display()
 
194
        gtk.main()
 
195
 
168
196
    def get_background_items(self, window, vfs_file):
 
197
        items = []
169
198
        file = vfs_file.get_uri()
170
199
        try:
171
200
            tree, path = WorkingTree.open_containing(file)
172
201
        except NotBranchError:
173
202
            item = nautilus.MenuItem('BzrNautilus::newtree',
174
 
                                 'Create new Bazaar tree',
 
203
                                 'Make directory versioned',
175
204
                                 'Create new Bazaar tree in this folder')
176
205
            item.connect('activate', self.newtree_cb, vfs_file)
177
206
            items.append(item)
178
207
 
179
208
            item = nautilus.MenuItem('BzrNautilus::clone',
180
 
                                 'Checkout',
 
209
                                 'Checkout Bazaar branch',
181
210
                                 'Checkout Existing Bazaar Branch')
182
211
            item.connect('activate', self.clone_cb, vfs_file)
183
212
            items.append(item)
184
213
 
185
214
            return items
186
215
 
187
 
        items = []
188
216
        item = nautilus.MenuItem('BzrNautilus::log',
189
217
                             'Log',
190
218
                             'Show Bazaar history')
191
219
        item.connect('activate', self.log_cb, vfs_file)
192
220
        items.append(item)
193
221
 
 
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
 
194
234
        item = nautilus.MenuItem('BzrNautilus::commit',
195
235
                             'Commit',
196
236
                             'Commit Changes')
215
255
                if not vfs_file.is_directory():
216
256
                    return
217
257
                item = nautilus.MenuItem('BzrNautilus::newtree',
218
 
                                     'Create new Bazaar tree',
 
258
                                     'Make directory versioned',
219
259
                                     'Create new Bazaar tree in %s' % vfs_file.get_name())
220
260
                item.connect('activate', self.newtree_cb, vfs_file)
221
261
                return item,
272
312
                items.append(item)
273
313
 
274
314
        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)