1
# Trivial Bazaar plugin for Nautilus
3
# Copyright (C) 2006 Jeff Bailey
4
# Copyright (C) 2006 Wouter van Heyst
5
# Copyright (C) 2006 Jelmer Vernooij
7
# Published under the GNU GPL
11
3
from bzrlib.bzrdir import BzrDir
12
4
from bzrlib.errors import NotBranchError
13
5
from bzrlib.workingtree import WorkingTree
14
from bzrlib.tree import file_status
16
7
from bzrlib.plugin import load_plugins
19
10
from bzrlib.plugins.gtk import cmd_visualise, cmd_gannotate
21
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider):
12
class BzrExtension(nautilus.MenuProvider):
22
13
def __init__(self):
126
117
if vfs_file.get_uri_scheme() != 'file':
129
from bzrlib.plugins.gtk.branch import BranchDialog
131
dialog = BranchDialog(vfs_file.get_name())
120
file = vfs_file.get_uri()
122
tree, path = WorkingTree.open_containing(file)
123
except NotBranchError:
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)
134
132
def commit_cb(self, menu, vfs_file=None):
135
133
# We can only cope with local files
142
140
except NotBranchError:
145
from bzrlib.plugins.gtk.commit import CommitDialog
146
dialog = CommitDialog(tree, path)
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)
150
150
def log_cb(self, menu, vfs_file):
151
151
# We can only cope with local files
168
def pull_cb(self, menu, vfs_file):
169
# We can only cope with local files
170
if vfs_file.get_uri_scheme() != 'file':
173
file = vfs_file.get_uri()
175
# We only want to continue here if we get a NotBranchError
177
tree, path = WorkingTree.open_containing(file)
178
except NotBranchError:
181
from bzrlib.plugins.gtk.pull import PullDialog
182
dialog = PullDialog(tree, path)
186
def merge_cb(self, menu, vfs_file):
187
# We can only cope with local files
188
if vfs_file.get_uri_scheme() != 'file':
191
file = vfs_file.get_uri()
193
# We only want to continue here if we get a NotBranchError
195
tree, path = WorkingTree.open_containing(file)
196
except NotBranchError:
199
from bzrlib.plugins.gtk.merge import MergeDialog
200
dialog = MergeDialog(tree, path)
204
168
def get_background_items(self, window, vfs_file):
206
169
file = vfs_file.get_uri()
208
171
tree, path = WorkingTree.open_containing(file)
209
172
except NotBranchError:
210
173
item = nautilus.MenuItem('BzrNautilus::newtree',
211
'Make directory versioned',
174
'Create new Bazaar tree',
212
175
'Create new Bazaar tree in this folder')
213
176
item.connect('activate', self.newtree_cb, vfs_file)
214
177
items.append(item)
216
179
item = nautilus.MenuItem('BzrNautilus::clone',
217
'Checkout Bazaar branch',
218
181
'Checkout Existing Bazaar Branch')
219
182
item.connect('activate', self.clone_cb, vfs_file)
220
183
items.append(item)
224
188
item = nautilus.MenuItem('BzrNautilus::log',
226
190
'Show Bazaar history')
227
191
item.connect('activate', self.log_cb, vfs_file)
228
192
items.append(item)
230
item = nautilus.MenuItem('BzrNautilus::pull',
232
'Pull from another branch')
233
item.connect('activate', self.pull_cb, vfs_file)
236
item = nautilus.MenuItem('BzrNautilus::merge',
238
'Merge from another branch')
239
item.connect('activate', self.merge_cb, vfs_file)
242
194
item = nautilus.MenuItem('BzrNautilus::commit',
244
196
'Commit Changes')
263
215
if not vfs_file.is_directory():
265
217
item = nautilus.MenuItem('BzrNautilus::newtree',
266
'Make directory versioned',
218
'Create new Bazaar tree',
267
219
'Create new Bazaar tree in %s' % vfs_file.get_name())
268
220
item.connect('activate', self.newtree_cb, vfs_file)
320
272
items.append(item)
324
def get_columns(self):
325
return nautilus.Column("BzrNautilus::bzr_status",
328
"Version control status"),
330
def update_file_info(self, file):
331
if file.get_uri_scheme() != 'file':
335
tree, path = WorkingTree.open_containing(file.get_uri())
336
except NotBranchError:
342
if tree.has_filename(path):
343
emblem = 'cvs-controlled'
345
id = tree.path2id(path)
347
delta = tree.changes_from(tree.branch.basis_tree())
348
if delta.touches_file_id(id):
349
emblem = 'cvs-modified'
351
for f, _, _ in delta.added:
356
for of, f, _, _, _, _ in delta.renamed:
358
status = 'renamed from %s' % f
360
elif tree.branch.basis_tree().has_filename(path):
361
emblem = 'cvs-removed'
364
# FIXME: Check for ignored files
365
status = 'unversioned'
367
if emblem is not None:
368
file.add_emblem(emblem)
369
file.add_string_attribute('bzr_status', status)