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
3
12
from bzrlib.bzrdir import BzrDir
4
13
from bzrlib.errors import NotBranchError
14
from bzrlib.errors import NoWorkingTree
15
from bzrlib.errors import UnsupportedProtocol
5
16
from bzrlib.workingtree import WorkingTree
17
from bzrlib.branch import Branch
6
18
from bzrlib.tree import file_status
8
20
from bzrlib.plugin import load_plugins
89
101
tree, path = WorkingTree.open_containing(file)
90
102
except NotBranchError:
91
BzrDir.create_branch_and_repo(file)
103
BzrDir.create_standalone_workingtree(file)
93
105
def remove_cb(self, menu, vfs_file):
94
106
# We can only cope with local files
118
130
if vfs_file.get_uri_scheme() != 'file':
121
from bzrlib.plugins.gtk.olive.branch import BranchDialog
133
from bzrlib.plugins.gtk.branch import BranchDialog
123
135
dialog = BranchDialog(vfs_file.get_name())
136
response = dialog.run()
137
if response != gtk.RESPONSE_NONE:
126
141
def commit_cb(self, menu, vfs_file=None):
127
142
# We can only cope with local files
131
146
file = vfs_file.get_uri()
133
150
tree, path = WorkingTree.open_containing(file)
134
except NotBranchError:
152
except NotBranchError, e:
155
except NoWorkingTree, e:
158
(branch, path) = Branch.open_containing(path)
159
except NotBranchError, e:
137
from bzrlib.plugins.gtk.olive.commit import CommitDialog
138
dialog = CommitDialog(tree, path)
162
from bzrlib.plugins.gtk.commit import CommitDialog
163
dialog = CommitDialog(tree, path, not branch)
164
response = dialog.run()
165
if response != gtk.RESPONSE_NONE:
142
169
def log_cb(self, menu, vfs_file):
143
170
# We can only cope with local files
187
def pull_cb(self, menu, vfs_file):
188
# We can only cope with local files
189
if vfs_file.get_uri_scheme() != 'file':
192
file = vfs_file.get_uri()
194
# We only want to continue here if we get a NotBranchError
196
tree, path = WorkingTree.open_containing(file)
197
except NotBranchError:
200
from bzrlib.plugins.gtk.pull import PullDialog
201
dialog = PullDialog(tree, path)
205
def merge_cb(self, menu, vfs_file):
206
# We can only cope with local files
207
if vfs_file.get_uri_scheme() != 'file':
210
file = vfs_file.get_uri()
212
# We only want to continue here if we get a NotBranchError
214
tree, path = WorkingTree.open_containing(file)
215
except NotBranchError:
218
from bzrlib.plugins.gtk.merge import MergeDialog
219
dialog = MergeDialog(tree, path)
160
223
def get_background_items(self, window, vfs_file):
162
225
file = vfs_file.get_uri()
164
227
tree, path = WorkingTree.open_containing(file)
228
except UnsupportedProtocol:
165
230
except NotBranchError:
166
231
item = nautilus.MenuItem('BzrNautilus::newtree',
167
232
'Make directory versioned',
183
248
item.connect('activate', self.log_cb, vfs_file)
184
249
items.append(item)
251
item = nautilus.MenuItem('BzrNautilus::pull',
253
'Pull from another branch')
254
item.connect('activate', self.pull_cb, vfs_file)
257
item = nautilus.MenuItem('BzrNautilus::merge',
259
'Merge from another branch')
260
item.connect('activate', self.merge_cb, vfs_file)
186
263
item = nautilus.MenuItem('BzrNautilus::commit',
188
265
'Commit Changes')
211
289
'Create new Bazaar tree in %s' % vfs_file.get_name())
212
290
item.connect('activate', self.newtree_cb, vfs_file)
215
file_class = tree.file_class(path)
217
if file_class == '?':
292
# Refresh the list of filestatuses in the working tree
293
if path not in wtfiles.keys():
295
for rpath, file_class, kind, id, entry in tree.list_files():
296
wtfiles[rpath] = file_class
300
if wtfiles[path] == '?':
218
301
item = nautilus.MenuItem('BzrNautilus::add',
220
303
'Add as versioned file')
226
309
'Ignore file for versioning')
227
310
item.connect('activate', self.ignore_cb, vfs_file)
228
311
items.append(item)
229
elif file_class == 'I':
312
elif wtfiles[path] == 'I':
230
313
item = nautilus.MenuItem('BzrNautilus::unignore',
232
315
'Unignore file for versioning')
233
316
item.connect('activate', self.unignore_cb, vfs_file)
234
317
items.append(item)
235
elif file_class == 'V':
318
elif wtfiles[path] == 'V':
236
319
item = nautilus.MenuItem('BzrNautilus::log',