25
25
# You can also install nautilus-bzr manually by copying it (or linking it from)
26
26
# ~/.local/share/nautilus-python/extensions/nautilus-bzr.py
28
from gi.repository import Gtk, Nautilus, GObject
28
from gi.repository import Gtk, GObject, Nautilus
29
29
from bzrlib.controldir import ControlDir
30
30
from bzrlib.errors import (
61
61
controldir, path = self._open_bzrdir(vfs_file)
62
62
tree = controldir.open_workingtree()
63
63
#FIXME: Add path to ignore file
66
65
def unignore_cb(self, menu, vfs_file):
67
66
# We can only cope with local files
68
67
controldir, path = self._open_bzrdir(vfs_file)
69
68
tree = controldir.open_workingtree()
73
71
def diff_cb(self, menu, vfs_file):
74
72
controldir, path = self._open_bzrdir(vfs_file)
121
119
def log_cb(self, menu, vfs_file):
120
from bzrlib.plugins.gtk.viz import BranchWindow
122
121
controldir, path = self._open_bzrdir(vfs_file)
123
122
branch = controldir.open_branch()
124
pp = start_viz_window(branch, [branch.last_revision()])
123
pp = BranchWindow(branch, [branch.last_revision()])
294
293
description="Last change revision"),
297
def update_file_info(self, file):
299
if file.get_uri_scheme() != 'file':
303
tree, path = WorkingTree.open_containing(file.get_uri())
304
except NotBranchError:
306
except NoWorkingTree:
309
nautilus_integration = self.check_branch_enabled(tree.branch)
310
if not nautilus_integration:
296
def _file_summary(self, tree, basis_tree, intertree, path):
316
id = tree.path2id(path)
300
file_id = tree.path2id(path)
318
302
if tree.is_ignored(path):
319
303
status = 'ignored'
320
304
emblem = 'bzr-ignored'
322
306
status = 'unversioned'
324
elif tree.has_filename(path):
325
emblem = 'bzr-controlled'
328
delta = tree.changes_from(tree.branch.basis_tree())
329
if delta.touches_file_id(id):
330
emblem = 'bzr-modified'
332
for f, _, _ in delta.added:
307
file_revision = "N/A"
308
elif tree.has_filename(path): # Still present
309
if not intertree.file_content_matches(file_id, file_id):
310
if not basis_tree.has_id(file_id):
334
311
emblem = 'bzr-added'
337
for of, f, _, _, _, _ in delta.renamed:
339
status = 'renamed from %s' % f
341
elif tree.branch.basis_tree().has_filename(path):
313
file_revision = "new file"
314
elif basis_tree.path2id(file_id) != path:
315
status = 'bzr-renamed'
316
status = 'renamed from %s' % basis_tree.path2id(file_id)
318
emblem = 'bzr-modified'
321
emblem = 'bzr-controlled'
323
elif basis_tree.has_filename(path):
342
324
emblem = 'bzr-removed'
343
325
status = 'removed'
345
327
# FIXME: Check for ignored files
346
328
status = 'unversioned'
348
if emblem is not None:
349
file.add_emblem(emblem)
350
file.add_string_attribute('bzr_status', status)
329
return (status, emblem, file_revision)
331
def update_file_info(self, vfs_file):
333
controldir, path = self._open_bzrdir(vfs_file)
334
except NotBranchError:
338
tree = controldir.open_workingtree()
339
except NoWorkingTree:
344
nautilus_integration = self.check_branch_enabled(tree.branch)
345
if not nautilus_integration:
348
basis_tree = tree.basis_tree()
349
intertree = InterTree.get(basis_tree, tree)
351
basis_tree.lock_read()
353
(status, emblem, file_revision) = self._file_summary(tree, basis_tree, intertree, path)
356
if emblem is not None:
357
vfs_file.add_emblem(emblem)
358
vfs_file.add_string_attribute('bzr_status', status)
359
vfs_file.add_string_attribute('bzr_revision', file_revision)
352
363
def check_branch_enabled(self, branch):
353
364
# Supports global disable, but there is currently no UI to do this