1
# Trivial Bazaar plugin for Nautilus
3
# Copyright (C) 2006 Jeff Bailey
4
# Copyright (C) 2006 Wouter van Heyst
5
# Copyright (C) 2006-2008 Jelmer Vernooij <jelmer@samba.org>
7
# Published under the GNU GPL
12
from bzrlib.branch import Branch
13
3
from bzrlib.bzrdir import BzrDir
14
from bzrlib.errors import NotBranchError, NoWorkingTree, UnsupportedProtocol
4
from bzrlib.errors import NotBranchError
5
from bzrlib.workingtree import WorkingTree
15
6
from bzrlib.tree import file_status
16
from bzrlib.workingtree import WorkingTree
17
from bzrlib.config import GlobalConfig
19
8
from bzrlib.plugin import load_plugins
22
from bzrlib.plugins.gtk import _i18n
23
from bzrlib.plugins.gtk.commands import cmd_gannotate, start_viz_window
25
print "Bazaar nautilus module initialized"
11
from bzrlib.plugins.gtk import cmd_visualise, cmd_gannotate
28
13
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider):
29
14
def __init__(self):
180
149
# We only want to continue here if we get a NotBranchError
182
branch, path = Branch.open_containing(file)
183
except NotBranchError:
186
pp = start_viz_window(branch, [branch.last_revision()])
190
def pull_cb(self, menu, vfs_file):
191
# We can only cope with local files
192
if vfs_file.get_uri_scheme() != 'file':
195
file = vfs_file.get_uri()
197
# We only want to continue here if we get a NotBranchError
199
tree, path = WorkingTree.open_containing(file)
200
except NotBranchError:
203
from bzrlib.plugins.gtk.pull import PullDialog
204
dialog = PullDialog(tree, path)
208
def merge_cb(self, menu, vfs_file):
209
# We can only cope with local files
210
if vfs_file.get_uri_scheme() != 'file':
213
file = vfs_file.get_uri()
215
# We only want to continue here if we get a NotBranchError
217
tree, path = WorkingTree.open_containing(file)
218
except NotBranchError:
221
from bzrlib.plugins.gtk.merge import MergeDialog
222
dialog = MergeDialog(tree, path)
151
tree, path = WorkingTree.open_containing(file)
152
except NotBranchError:
155
vis = cmd_visualise()
226
160
def get_background_items(self, window, vfs_file):
228
162
file = vfs_file.get_uri()
231
164
tree, path = WorkingTree.open_containing(file)
232
disabled_flag = self.check_branch_enabled(tree.branch)
233
except UnsupportedProtocol:
235
165
except NotBranchError:
236
disabled_flag = self.check_branch_enabled()
237
166
item = nautilus.MenuItem('BzrNautilus::newtree',
238
'Make directory versioned',
167
'Create new Bazaar tree',
239
168
'Create new Bazaar tree in this folder')
240
169
item.connect('activate', self.newtree_cb, vfs_file)
241
170
items.append(item)
243
172
item = nautilus.MenuItem('BzrNautilus::clone',
244
'Checkout Bazaar branch ...',
245
174
'Checkout Existing Bazaar Branch')
246
175
item.connect('activate', self.clone_cb, vfs_file)
247
176
items.append(item)
250
except NoWorkingTree:
253
if disabled_flag == 'False':
254
item = nautilus.MenuItem('BzrNautilus::enable',
255
'Enable Bazaar Plugin for this Branch',
256
'Enable Bazaar plugin for nautilus')
257
item.connect('activate', self.toggle_integration, 'True', vfs_file)
260
item = nautilus.MenuItem('BzrNautilus::disable',
261
'Disable Bazaar Plugin this Branch',
262
'Disable Bazaar plugin for nautilus')
263
item.connect('activate', self.toggle_integration, 'False', vfs_file)
266
180
item = nautilus.MenuItem('BzrNautilus::log',
268
182
'Show Bazaar history')
269
183
item.connect('activate', self.log_cb, vfs_file)
270
184
items.append(item)
272
item = nautilus.MenuItem('BzrNautilus::pull',
274
'Pull from another branch')
275
item.connect('activate', self.pull_cb, vfs_file)
278
item = nautilus.MenuItem('BzrNautilus::merge',
280
'Merge from another branch')
281
item.connect('activate', self.merge_cb, vfs_file)
284
186
item = nautilus.MenuItem('BzrNautilus::commit',
286
188
'Commit Changes')
287
189
item.connect('activate', self.commit_cb, vfs_file)
288
190
items.append(item)
292
195
def get_file_items(self, window, files):
296
198
for vfs_file in files:
297
199
# We can only cope with local files
298
200
if vfs_file.get_uri_scheme() != 'file':
301
203
file = vfs_file.get_uri()
303
205
tree, path = WorkingTree.open_containing(file)
304
disabled_flag = self.check_branch_enabled(tree.branch)
305
206
except NotBranchError:
306
disabled_flag = self.check_branch_enabled()
307
207
if not vfs_file.is_directory():
310
if disabled_flag == 'False':
313
209
item = nautilus.MenuItem('BzrNautilus::newtree',
314
'Make directory versioned',
210
'Create new Bazaar tree',
315
211
'Create new Bazaar tree in %s' % vfs_file.get_name())
316
212
item.connect('activate', self.newtree_cb, vfs_file)
318
except NoWorkingTree:
320
# Refresh the list of filestatuses in the working tree
321
if path not in wtfiles.keys():
323
for rpath, file_class, kind, id, entry in tree.list_files():
324
wtfiles[rpath] = file_class
328
if wtfiles[path] == '?':
215
file_class = tree.file_class(path)
217
if file_class == '?':
329
218
item = nautilus.MenuItem('BzrNautilus::add',
331
220
'Add as versioned file')