/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: 2011-11-17 21:27:30 UTC
  • Revision ID: jelmer@samba.org-20111117212730-j5onzc4tsatiyoqc
Initial work on fixing nautilus-bzr.

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>
6
 
#
7
 
# Published under the GNU GPL
8
 
 
9
 
import gtk
10
 
import nautilus
11
 
import bzrlib
12
 
from bzrlib.branch import Branch
13
 
from bzrlib.bzrdir import BzrDir
14
 
from bzrlib.errors import NotBranchError, NoWorkingTree, UnsupportedProtocol
15
 
from bzrlib.tree import file_status
 
5
# Copyright (C) 2006-2011 Jelmer Vernooij <jelmer@samba.org>
 
6
#
 
7
# This program is free software; you can redistribute it and/or modify
 
8
# it under the terms of the GNU General Public License as published by
 
9
# the Free Software Foundation; either version 3 of the License, or
 
10
# (at your option) any later version.
 
11
 
 
12
# This program is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
# GNU General Public License for more details.
 
16
 
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with this program; if not, write to the Free Software
 
19
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
20
 
 
21
# Installation:
 
22
# setup.py can install nautilus-bzr to the right system folder, if pkg-config
 
23
# is present.
 
24
#
 
25
# You can also install nautilus-bzr manually by copying it (or linking it from)
 
26
# ~/.local/share/nautilus-python/extensions/nautilus-bzr.py
 
27
 
 
28
from gi.repository import Gtk, Nautilus, GObject
 
29
from bzrlib.controldir import ControlDir
 
30
from bzrlib.errors import (
 
31
    NotBranchError,
 
32
    NoWorkingTree,
 
33
    )
 
34
from bzrlib.tree import InterTree
16
35
from bzrlib.workingtree import WorkingTree
17
 
from bzrlib.config import GlobalConfig
18
36
 
19
37
from bzrlib.plugin import load_plugins
20
38
load_plugins()
21
39
 
22
 
from bzrlib.plugins.gtk import _i18n, cmd_visualise, cmd_gannotate
23
 
 
24
 
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider):
 
40
 
 
41
class BazaarExtension(Nautilus.MenuProvider, Nautilus.ColumnProvider,
 
42
        Nautilus.InfoProvider, Nautilus.PropertyPageProvider, GObject.GObject):
 
43
    """Nautilus extension providing Bazaar integration."""
 
44
 
25
45
    def __init__(self):
26
46
        pass
27
47
 
 
48
    @classmethod
 
49
    def _open_bzrdir(cls, vfs_file):
 
50
        uri = vfs_file.get_uri()
 
51
        controldir, path = ControlDir.open_containing(uri)
 
52
        return controldir, path
 
53
 
28
54
    def add_cb(self, menu, vfs_file):
29
 
        # We can only cope with local files
30
 
        if vfs_file.get_uri_scheme() != 'file':
31
 
            return
32
 
 
33
 
        file = vfs_file.get_uri()
34
 
        try:
35
 
            tree, path = WorkingTree.open_containing(file)
36
 
        except NotBranchError:
37
 
            return
38
 
 
 
55
        controldir, path = self._open_bzrdir(vfs_file)
 
56
        tree = controldir.open_workingtree()
39
57
        tree.add(path)
40
58
 
41
 
        return
42
 
 
43
59
    def ignore_cb(self, menu, vfs_file):
44
60
        # We can only cope with local files
45
 
        if vfs_file.get_uri_scheme() != 'file':
46
 
            return
47
 
 
48
 
        file = vfs_file.get_uri()
49
 
        try:
50
 
            tree, path = WorkingTree.open_containing(file)
51
 
        except NotBranchError:
52
 
            return
53
 
 
54
 
        #FIXME
55
 
 
 
61
        controldir, path = self._open_bzrdir(vfs_file)
 
62
        tree = controldir.open_workingtree()
 
63
        #FIXME: Add path to ignore file
56
64
        return
57
65
 
58
66
    def unignore_cb(self, menu, vfs_file):
59
67
        # We can only cope with local files
60
 
        if vfs_file.get_uri_scheme() != 'file':
61
 
            return
62
 
 
63
 
        file = vfs_file.get_uri()
64
 
        try:
65
 
            tree, path = WorkingTree.open_containing(file)
66
 
        except NotBranchError:
67
 
            return
68
 
 
 
68
        controldir, path = self._open_bzrdir(vfs_file)
 
69
        tree = controldir.open_workingtree()
69
70
        #FIXME
70
 
 
71
71
        return
72
72
 
73
73
    def diff_cb(self, menu, vfs_file):
74
 
        # We can only cope with local files
75
 
        if vfs_file.get_uri_scheme() != 'file':
76
 
            return
77
 
 
78
 
        file = vfs_file.get_uri()
79
 
        try:
80
 
            tree, path = WorkingTree.open_containing(file)
81
 
        except NotBranchError:
82
 
            return
83
 
 
 
74
        controldir, path = self._open_bzrdir(vfs_file)
 
75
        tree = controldir.open_workingtree()
84
76
        from bzrlib.plugins.gtk.diff import DiffWindow
85
77
        window = DiffWindow()
86
 
        window.set_diff(tree.branch.nick, tree, tree.branch.basis_tree())
 
78
        window.set_diff(tree.branch._get_nick(local=True), tree, 
 
79
                        tree.branch.basis_tree())
87
80
        window.show()
88
81
 
89
82
        return
90
83
 
91
84
    def newtree_cb(self, menu, vfs_file):
92
 
        # We can only cope with local files
93
 
        if vfs_file.get_uri_scheme() != 'file':
94
 
            return
95
 
 
96
 
        file = vfs_file.get_uri()
97
 
 
98
 
        # We only want to continue here if we get a NotBranchError
99
 
        try:
100
 
            tree, path = WorkingTree.open_containing(file)
101
 
        except NotBranchError:
102
 
            BzrDir.create_standalone_workingtree(file)
 
85
        controldir, path = self._open_bzrdir(vfs_file)
 
86
        controldir.create_workingtree()
103
87
 
104
88
    def remove_cb(self, menu, vfs_file):
105
 
        # We can only cope with local files
106
 
        if vfs_file.get_uri_scheme() != 'file':
107
 
            return
108
 
 
109
 
        file = vfs_file.get_uri()
110
 
        try:
111
 
            tree, path = WorkingTree.open_containing(file)
112
 
        except NotBranchError:
113
 
            return
114
 
 
 
89
        controldir, path = self._open_bzrdir(vfs_file)
 
90
        tree = controldir.open_workingtree()
115
91
        tree.remove(path)
116
92
 
117
93
    def annotate_cb(self, menu, vfs_file):
118
 
        # We can only cope with local files
119
 
        if vfs_file.get_uri_scheme() != 'file':
120
 
            return
121
 
 
122
 
        file = vfs_file.get_uri()
123
 
 
124
 
        vis = cmd_gannotate()
125
 
        vis.run(file)
 
94
        from bzrlib.plugins.gtk.annotate.gannotate import GAnnotateWindow
 
95
        controldir, path = self._open_bzrdir(vfs_file)
 
96
        win = GAnnotateWindow()
 
97
        win.annotate(controldir.open_workingtree(), controldir.open_branch(), path)
 
98
        Gtk.main()
126
99
 
127
100
    def clone_cb(self, menu, vfs_file=None):
128
 
        # We can only cope with local files
129
 
        if vfs_file.get_uri_scheme() != 'file':
130
 
            return
131
 
 
132
101
        from bzrlib.plugins.gtk.branch import BranchDialog
133
 
        
 
102
        controldir, path = self._open_bzrdir(vfs_file)
 
103
 
134
104
        dialog = BranchDialog(vfs_file.get_name())
135
105
        response = dialog.run()
136
 
        if response != gtk.RESPONSE_NONE:
 
106
        if response != Gtk.ResponseType.NONE:
137
107
            dialog.hide()
138
108
            dialog.destroy()
139
 
 
 
109
 
140
110
    def commit_cb(self, menu, vfs_file=None):
141
 
        # We can only cope with local files
142
 
        if vfs_file.get_uri_scheme() != 'file':
143
 
            return
144
 
 
145
 
        file = vfs_file.get_uri()
146
 
        tree = None
147
 
        branch = None
148
 
        try:
149
 
            tree, path = WorkingTree.open_containing(file)
150
 
            branch = tree.branch
151
 
        except NotBranchError, e:
152
 
            path = e.path
153
 
            #return
154
 
        except NoWorkingTree, e:
155
 
            path = e.base
156
 
            try:
157
 
                (branch, path) = Branch.open_containing(path)
158
 
            except NotBranchError, e:
159
 
                path = e.path
 
111
        controldir, path = self._open_bzrdir(vfs_file)
 
112
        tree = controldir.open_workingtree()
160
113
 
161
114
        from bzrlib.plugins.gtk.commit import CommitDialog
162
115
        dialog = CommitDialog(tree, path)
163
116
        response = dialog.run()
164
 
        if response != gtk.RESPONSE_NONE:
 
117
        if response != Gtk.ResponseType.NONE:
165
118
            dialog.hide()
166
119
            dialog.destroy()
167
120
 
168
121
    def log_cb(self, menu, vfs_file):
169
 
        # We can only cope with local files
170
 
        if vfs_file.get_uri_scheme() != 'file':
171
 
            return
172
 
 
173
 
        file = vfs_file.get_uri()
174
 
 
175
 
        # We only want to continue here if we get a NotBranchError
176
 
        try:
177
 
            tree, path = WorkingTree.open_containing(file)
178
 
        except NotBranchError:
179
 
            return
180
 
 
181
 
        vis = cmd_visualise()
182
 
        vis.run(file)
183
 
 
184
 
        return
 
122
        controldir, path = self._open_bzrdir(vfs_file)
 
123
        branch = controldir.open_branch()
 
124
        pp = start_viz_window(branch, [branch.last_revision()])
 
125
        pp.show()
 
126
        Gtk.main()
185
127
 
186
128
    def pull_cb(self, menu, vfs_file):
187
 
        # We can only cope with local files
188
 
        if vfs_file.get_uri_scheme() != 'file':
189
 
            return
190
 
 
191
 
        file = vfs_file.get_uri()
192
 
 
193
 
        # We only want to continue here if we get a NotBranchError
194
 
        try:
195
 
            tree, path = WorkingTree.open_containing(file)
196
 
        except NotBranchError:
197
 
            return
198
 
 
 
129
        controldir, path = self._open_bzrdir(vfs_file)
 
130
        tree = controldir.open_workingtree()
199
131
        from bzrlib.plugins.gtk.pull import PullDialog
200
132
        dialog = PullDialog(tree, path)
201
133
        dialog.display()
202
 
        gtk.main()
 
134
        Gtk.main()
203
135
 
204
136
    def merge_cb(self, menu, vfs_file):
205
 
        # We can only cope with local files
206
 
        if vfs_file.get_uri_scheme() != 'file':
207
 
            return
208
 
 
209
 
        file = vfs_file.get_uri()
210
 
 
211
 
        # We only want to continue here if we get a NotBranchError
212
 
        try:
213
 
            tree, path = WorkingTree.open_containing(file)
214
 
        except NotBranchError:
215
 
            return
216
 
 
 
137
        controldir, path = self._open_bzrdir(vfs_file)
 
138
        tree = controldir.open_workingtree()
217
139
        from bzrlib.plugins.gtk.merge import MergeDialog
218
140
        dialog = MergeDialog(tree, path)
219
 
        dialog.display()
220
 
        gtk.main()
 
141
        dialog.run()
 
142
        dialog.destroy()
221
143
 
222
144
    def get_background_items(self, window, vfs_file):
223
 
        items = []
224
 
        file = vfs_file.get_uri()
225
 
 
226
145
        try:
227
 
            tree, path = WorkingTree.open_containing(file)
228
 
            disabled_flag = self.check_branch_enabled(tree.branch)
229
 
        except UnsupportedProtocol:
 
146
            controldir, path = self._open_bzrdir(vfs_file)
 
147
        except NotBranchError:
230
148
            return
 
149
        try:
 
150
            branch = controldir.open_branch()
231
151
        except NotBranchError:
232
 
            disabled_flag = self.check_branch_enabled()
233
 
            item = nautilus.MenuItem('BzrNautilus::newtree',
 
152
            items = []
 
153
            item = Nautilus.MenuItem('BzrNautilus::newtree',
234
154
                                 'Make directory versioned',
235
155
                                 'Create new Bazaar tree in this folder')
236
156
            item.connect('activate', self.newtree_cb, vfs_file)
237
157
            items.append(item)
238
158
 
239
 
            item = nautilus.MenuItem('BzrNautilus::clone',
240
 
                                 'Checkout Bazaar branch',
 
159
            item = Nautilus.MenuItem('BzrNautilus::clone',
 
160
                                 'Checkout Bazaar branch ...',
241
161
                                 'Checkout Existing Bazaar Branch')
242
162
            item.connect('activate', self.clone_cb, vfs_file)
243
163
            items.append(item)
244
 
 
245
164
            return items
246
 
        except NoWorkingTree:
247
 
            return
248
 
        
249
 
        if disabled_flag == 'False':
250
 
            item = nautilus.MenuItem('BzrNautilus::enable',
 
165
 
 
166
        items = []
 
167
 
 
168
        nautilus_integration = self.check_branch_enabled(branch)
 
169
        if not nautilus_integration:
 
170
            item = Nautilus.MenuItem('BzrNautilus::enable',
251
171
                                     'Enable Bazaar Plugin for this Branch',
252
172
                                     'Enable Bazaar plugin for nautilus')
253
 
            item.connect('activate', self.toggle_integration, 'True', vfs_file)
254
 
            return item,
 
173
            item.connect('activate', self.toggle_integration, True, vfs_file)
 
174
            return [item]
255
175
        else:
256
 
            item = nautilus.MenuItem('BzrNautilus::disable',
257
 
                                      'Disable Bazaar Plugin for the Branch',
258
 
                                      'Disable Bazaar plugin for nautilus')
259
 
            item.connect('activate', self.toggle_integration, 'False', vfs_file)
 
176
            item = Nautilus.MenuItem('BzrNautilus::disable',
 
177
                                     'Disable Bazaar Plugin this Branch',
 
178
                                     'Disable Bazaar plugin for nautilus')
 
179
            item.connect('activate', self.toggle_integration, False, vfs_file)
260
180
            items.append(item)
261
181
 
262
 
        item = nautilus.MenuItem('BzrNautilus::log',
263
 
                             'Log',
 
182
        item = Nautilus.MenuItem('BzrNautilus::log',
 
183
                             'History ...',
264
184
                             'Show Bazaar history')
265
185
        item.connect('activate', self.log_cb, vfs_file)
266
186
        items.append(item)
267
187
 
268
 
        item = nautilus.MenuItem('BzrNautilus::pull',
269
 
                             'Pull',
 
188
        item = Nautilus.MenuItem('BzrNautilus::pull',
 
189
                             'Pull ...',
270
190
                             'Pull from another branch')
271
191
        item.connect('activate', self.pull_cb, vfs_file)
272
192
        items.append(item)
273
193
 
274
 
        item = nautilus.MenuItem('BzrNautilus::merge',
275
 
                             'Merge',
276
 
                             'Merge from another branch')
277
 
        item.connect('activate', self.merge_cb, vfs_file)
278
 
        items.append(item)
 
194
        try:
 
195
            tree = controldir.open_workingtree()
 
196
        except NoWorkingTree:
 
197
            item = Nautilus.MenuItem('BzrNautilus::create_tree',
 
198
                                 'Create working tree...',
 
199
                                 'Create a working tree for this branch')
 
200
            item.connect('activate', self.create_tree_cb, vfs_file)
 
201
            items.append(item)
 
202
        else:
 
203
            item = Nautilus.MenuItem('BzrNautilus::merge',
 
204
                                 'Merge ...',
 
205
                                 'Merge from another branch')
 
206
            item.connect('activate', self.merge_cb, vfs_file)
 
207
            items.append(item)
279
208
 
280
 
        item = nautilus.MenuItem('BzrNautilus::commit',
281
 
                             'Commit',
282
 
                             'Commit Changes')
283
 
        item.connect('activate', self.commit_cb, vfs_file)
284
 
        items.append(item)
 
209
            item = Nautilus.MenuItem('BzrNautilus::commit',
 
210
                                 'Commit ...',
 
211
                                 'Commit Changes')
 
212
            item.connect('activate', self.commit_cb, vfs_file)
 
213
            items.append(item)
285
214
 
286
215
        return items
287
216
 
288
217
    def get_file_items(self, window, files):
289
218
        items = []
290
 
        
291
 
        wtfiles = {}
 
219
 
292
220
        for vfs_file in files:
293
 
            # We can only cope with local files
294
 
            if vfs_file.get_uri_scheme() != 'file':
295
 
                continue
 
221
            controldir, path = self._open_bzrdir(vfs_file)
296
222
 
297
 
            file = vfs_file.get_uri()
298
223
            try:
299
 
                tree, path = WorkingTree.open_containing(file)
300
 
                disabled_flag = self.check_branch_enabled(tree.branch)
301
 
            except NotBranchError:
302
 
                disabled_flag = self.check_branch_enabled()
303
 
                if not vfs_file.is_directory():
304
 
                    continue
305
 
 
306
 
                if disabled_flag == 'False':
307
 
                    return
308
 
 
309
 
                item = nautilus.MenuItem('BzrNautilus::newtree',
310
 
                                     'Make directory versioned',
311
 
                                     'Create new Bazaar tree in %s' % vfs_file.get_name())
312
 
                item.connect('activate', self.newtree_cb, vfs_file)
313
 
                return item,
 
224
                tree = controldir.open_workingtree()
314
225
            except NoWorkingTree:
315
226
                continue
316
 
            # Refresh the list of filestatuses in the working tree
317
 
            if path not in wtfiles.keys():
318
 
                tree.lock_read()
319
 
                for rpath, file_class, kind, id, entry in tree.list_files():
320
 
                    wtfiles[rpath] = file_class
321
 
                tree.unlock()
322
 
                wtfiles[u''] = 'V'
323
 
 
324
 
            if wtfiles[path] == '?':
325
 
                item = nautilus.MenuItem('BzrNautilus::add',
 
227
 
 
228
            nautilus_integration = self.check_branch_enabled(tree.branch)
 
229
            if not nautilus_integration:
 
230
                continue
 
231
 
 
232
            file_id = tree.path2id(path)
 
233
            if file_id is None:
 
234
                item = Nautilus.MenuItem('BzrNautilus::add',
326
235
                                     'Add',
327
236
                                     'Add as versioned file')
328
237
                item.connect('activate', self.add_cb, vfs_file)
329
238
                items.append(item)
330
239
 
331
 
                item = nautilus.MenuItem('BzrNautilus::ignore',
 
240
                item = Nautilus.MenuItem('BzrNautilus::ignore',
332
241
                                     'Ignore',
333
242
                                     'Ignore file for versioning')
334
243
                item.connect('activate', self.ignore_cb, vfs_file)
335
244
                items.append(item)
336
 
            elif wtfiles[path] == 'I':
337
 
                item = nautilus.MenuItem('BzrNautilus::unignore',
 
245
            elif tree.is_ignored(path):
 
246
                item = Nautilus.MenuItem('BzrNautilus::unignore',
338
247
                                     'Unignore',
339
248
                                     'Unignore file for versioning')
340
249
                item.connect('activate', self.unignore_cb, vfs_file)
341
250
                items.append(item)
342
 
            elif wtfiles[path] == 'V':
343
 
                item = nautilus.MenuItem('BzrNautilus::log',
344
 
                                 'Log',
 
251
            else:
 
252
                item = Nautilus.MenuItem('BzrNautilus::log',
 
253
                                 'History ...',
345
254
                                 'List changes')
346
255
                item.connect('activate', self.log_cb, vfs_file)
347
256
                items.append(item)
348
257
 
349
 
                item = nautilus.MenuItem('BzrNautilus::diff',
350
 
                                 'Diff',
351
 
                                 'Show differences')
352
 
                item.connect('activate', self.diff_cb, vfs_file)
353
 
                items.append(item)
354
 
 
355
 
                item = nautilus.MenuItem('BzrNautilus::remove',
 
258
                intertree = InterTree.get(tree.basis_tree(), tree)
 
259
                if not intertree.file_content_matches(file_id, file_id):
 
260
                    item = Nautilus.MenuItem('BzrNautilus::diff',
 
261
                                     'View Changes ...',
 
262
                                     'Show differences')
 
263
                    item.connect('activate', self.diff_cb, vfs_file)
 
264
                    items.append(item)
 
265
 
 
266
                    item = Nautilus.MenuItem('BzrNautilus::commit',
 
267
                                 'Commit ...',
 
268
                                 'Commit Changes')
 
269
                    item.connect('activate', self.commit_cb, vfs_file)
 
270
                    items.append(item)
 
271
 
 
272
                item = Nautilus.MenuItem('BzrNautilus::remove',
356
273
                                     'Remove',
357
274
                                     'Remove this file from versioning')
358
275
                item.connect('activate', self.remove_cb, vfs_file)
359
276
                items.append(item)
360
277
 
361
 
                item = nautilus.MenuItem('BzrNautilus::annotate',
362
 
                             'Annotate',
 
278
                item = Nautilus.MenuItem('BzrNautilus::annotate',
 
279
                             'Annotate ...',
363
280
                             'Annotate File Data')
364
281
                item.connect('activate', self.annotate_cb, vfs_file)
365
282
                items.append(item)
366
 
 
367
 
                item = nautilus.MenuItem('BzrNautilus::commit',
368
 
                             'Commit',
369
 
                             'Commit Changes')
370
 
                item.connect('activate', self.commit_cb, vfs_file)
371
 
                items.append(item)
372
 
 
373
283
        return items
374
284
 
375
285
    def get_columns(self):
376
 
        return nautilus.Column("BzrNautilus::bzr_status",
377
 
                               "bzr_status",
378
 
                               "Bzr Status",
379
 
                               "Version control status"),
 
286
        return [
 
287
            Nautilus.Column(name="BzrNautilus::bzr_status",
 
288
                            attribute="bzr_status",
 
289
                            label="Status",
 
290
                            description="Version control status"),
 
291
            Nautilus.Column(name="BzrNautilus::bzr_revision",
 
292
                            attribute="bzr_revision",
 
293
                            label="Revision",
 
294
                            description="Last change revision"),
 
295
            ]
380
296
 
381
297
    def update_file_info(self, file):
382
298
 
390
306
        except NoWorkingTree:
391
307
            return   
392
308
 
393
 
        disabled_flag = self.check_branch_enabled(tree.branch)
394
 
        if disabled_flag == 'False':
 
309
        nautilus_integration = self.check_branch_enabled(tree.branch)
 
310
        if not nautilus_integration:
395
311
            return
396
312
 
397
313
        emblem = None
398
314
        status = None
399
315
 
400
 
        if tree.has_filename(path):
 
316
        id = tree.path2id(path)
 
317
        if id == None:
 
318
            if tree.is_ignored(path):
 
319
                status = 'ignored'
 
320
                emblem = 'bzr-ignored'
 
321
            else:
 
322
                status = 'unversioned'
 
323
                        
 
324
        elif tree.has_filename(path):
401
325
            emblem = 'bzr-controlled'
402
326
            status = 'unchanged'
403
 
            id = tree.path2id(path)
404
327
 
405
328
            delta = tree.changes_from(tree.branch.basis_tree())
406
329
            if delta.touches_file_id(id):
421
344
        else:
422
345
            # FIXME: Check for ignored files
423
346
            status = 'unversioned'
424
 
        
 
347
 
425
348
        if emblem is not None:
426
349
            file.add_emblem(emblem)
427
350
        file.add_string_attribute('bzr_status', status)
428
351
 
429
 
    def check_branch_enabled(self, branch=None):
 
352
    def check_branch_enabled(self, branch):
430
353
        # Supports global disable, but there is currently no UI to do this
431
 
        config = GlobalConfig()
432
 
        disabled_flag = config.get_user_option('nautilus_integration')
433
 
        if disabled_flag != 'False':
434
 
            if branch is not None:
435
 
                config = branch.get_config()
436
 
                disabled_flag = config.get_user_option('nautilus_integration')
437
 
        return disabled_flag
438
 
 
439
 
    def toggle_integration(self, menu, action, vfs_file=None):
440
 
        try:
441
 
            tree, path = WorkingTree.open_containing(vfs_file.get_uri())
442
 
        except NotBranchError:
443
 
            return
444
 
        except NoWorkingTree:
445
 
            return
446
 
        branch = tree.branch
447
 
        if branch is None:
448
 
            config = GlobalConfig()
449
 
        else:
450
 
            config = branch.get_config()
451
 
        config.set_user_option('nautilus_integration', action)
452
 
 
 
354
        config = branch.get_config_stack()
 
355
        return config.get("nautilus_integration")
 
356
 
 
357
    def toggle_integration(self, menu, action, vfs_file):
 
358
        controldir = self._open_bzrdir(vfs_file)
 
359
        branch = controldir.open_branch()
 
360
        config = branch.get_config_stack()
 
361
        config.set("nautilus_integration", action)