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
8
7
from bzrlib.plugin import load_plugins
11
10
from bzrlib.plugins.gtk import cmd_visualise, cmd_gannotate
13
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider):
12
class BzrExtension(nautilus.MenuProvider):
14
13
def __init__(self):
118
117
if vfs_file.get_uri_scheme() != 'file':
121
from bzrlib.plugins.gtk.branch import BranchDialog
123
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)
126
132
def commit_cb(self, menu, vfs_file=None):
127
133
# We can only cope with local files
134
140
except NotBranchError:
137
from bzrlib.plugins.gtk.commit import CommitDialog
138
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)
142
150
def log_cb(self, menu, vfs_file):
143
151
# 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.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.merge import MergeDialog
192
dialog = MergeDialog(tree, path)
196
168
def get_background_items(self, window, vfs_file):
198
169
file = vfs_file.get_uri()
200
171
tree, path = WorkingTree.open_containing(file)
201
172
except NotBranchError:
202
173
item = nautilus.MenuItem('BzrNautilus::newtree',
203
'Make directory versioned',
174
'Create new Bazaar tree',
204
175
'Create new Bazaar tree in this folder')
205
176
item.connect('activate', self.newtree_cb, vfs_file)
206
177
items.append(item)
208
179
item = nautilus.MenuItem('BzrNautilus::clone',
209
'Checkout Bazaar branch',
210
181
'Checkout Existing Bazaar Branch')
211
182
item.connect('activate', self.clone_cb, vfs_file)
212
183
items.append(item)
216
188
item = nautilus.MenuItem('BzrNautilus::log',
218
190
'Show Bazaar history')
219
191
item.connect('activate', self.log_cb, vfs_file)
220
192
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)
234
194
item = nautilus.MenuItem('BzrNautilus::commit',
236
196
'Commit Changes')
255
215
if not vfs_file.is_directory():
257
217
item = nautilus.MenuItem('BzrNautilus::newtree',
258
'Make directory versioned',
218
'Create new Bazaar tree',
259
219
'Create new Bazaar tree in %s' % vfs_file.get_name())
260
220
item.connect('activate', self.newtree_cb, vfs_file)
312
272
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)