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
8
from bzrlib.plugin import load_plugins
10
11
from bzrlib.plugins.gtk import cmd_visualise, cmd_gannotate
12
class BzrExtension(nautilus.MenuProvider):
13
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider):
13
14
def __init__(self):
117
118
if vfs_file.get_uri_scheme() != 'file':
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)
121
from bzrlib.plugins.gtk.olive.branch import BranchDialog
123
dialog = BranchDialog(vfs_file.get_name())
132
126
def commit_cb(self, menu, vfs_file=None):
133
127
# We can only cope with local files
140
134
except NotBranchError:
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)
150
142
def log_cb(self, menu, vfs_file):
151
143
# We can only cope with local files
160
def pull_cb(self, menu, vfs_file):
161
# We can only cope with local files
162
if vfs_file.get_uri_scheme() != 'file':
165
file = vfs_file.get_uri()
167
# We only want to continue here if we get a NotBranchError
169
tree, path = WorkingTree.open_containing(file)
170
except NotBranchError:
173
from bzrlib.plugins.gtk.olive.pull import PullDialog
174
dialog = PullDialog(tree, path)
178
def merge_cb(self, menu, vfs_file):
179
# We can only cope with local files
180
if vfs_file.get_uri_scheme() != 'file':
183
file = vfs_file.get_uri()
185
# We only want to continue here if we get a NotBranchError
187
tree, path = WorkingTree.open_containing(file)
188
except NotBranchError:
191
from bzrlib.plugins.gtk.olive.merge import MergeDialog
192
dialog = MergeDialog(tree, path)
168
196
def get_background_items(self, window, vfs_file):
169
198
file = vfs_file.get_uri()
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)
179
208
item = nautilus.MenuItem('BzrNautilus::clone',
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)
188
216
item = nautilus.MenuItem('BzrNautilus::log',
190
218
'Show Bazaar history')
191
219
item.connect('activate', self.log_cb, vfs_file)
192
220
items.append(item)
222
item = nautilus.MenuItem('BzrNautilus::pull',
224
'Pull from another branch')
225
item.connect('activate', self.pull_cb, vfs_file)
228
item = nautilus.MenuItem('BzrNautilus::merge',
230
'Merge from another branch')
231
item.connect('activate', self.merge_cb, vfs_file)
194
234
item = nautilus.MenuItem('BzrNautilus::commit',
196
236
'Commit Changes')
215
255
if not vfs_file.is_directory():
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)
272
312
items.append(item)
316
def get_columns(self):
317
return nautilus.Column("BzrNautilus::bzr_status",
320
"Version control status"),
322
def update_file_info(self, file):
323
if file.get_uri_scheme() != 'file':
327
tree, path = WorkingTree.open_containing(file.get_uri())
328
except NotBranchError:
334
if tree.has_filename(path):
335
emblem = 'cvs-controlled'
337
id = tree.path2id(path)
339
delta = tree.changes_from(tree.branch.basis_tree())
340
if delta.touches_file_id(id):
341
emblem = 'cvs-modified'
343
for f, _, _ in delta.added:
348
for of, f, _, _, _, _ in delta.renamed:
350
status = 'renamed from %s' % f
352
elif tree.branch.basis_tree().has_filename(path):
353
emblem = 'cvs-removed'
356
# FIXME: Check for ignored files
357
status = 'unversioned'
359
if emblem is not None:
360
file.add_emblem(emblem)
361
file.add_string_attribute('bzr_status', status)