bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
0.5.1
by Jelmer Vernooij
Start working on bzr integration plugin for nautilus |
1 |
import nautilus |
2 |
import bzrlib |
|
3 |
from bzrlib.bzrdir import BzrDir |
|
0.5.2
by jbailey at ubuntu
Bring this to a state where it actually works. Specifically: |
4 |
from bzrlib.errors import NotBranchError |
5 |
from bzrlib.workingtree import WorkingTree |
|
88
by Jelmer Vernooij
Show column with file status. |
6 |
from bzrlib.tree import file_status |
0.5.1
by Jelmer Vernooij
Start working on bzr integration plugin for nautilus |
7 |
|
0.7.1
by Wouter van Heyst
use the bzrlib method of loading plugins, takes care of ~/.bazaar/plugins |
8 |
from bzrlib.plugin import load_plugins |
9 |
load_plugins() |
|
10 |
||
81
by Jelmer Vernooij
Remove unnecessary "#!/usr/bin/python" shebang lines (fixes #59125). |
11 |
from bzrlib.plugins.gtk import cmd_visualise, cmd_gannotate |
0.6.2
by Jelmer Vernooij
Add 'Annotate' menu entry that uses the gannotate bzr plugin |
12 |
|
88
by Jelmer Vernooij
Show column with file status. |
13 |
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider): |
0.5.1
by Jelmer Vernooij
Start working on bzr integration plugin for nautilus |
14 |
def __init__(self): |
15 |
pass
|
|
16 |
||
0.5.4
by jbailey at ubuntu
Add 'add' function. Give framework for other callbacks. |
17 |
def add_cb(self, menu, vfs_file): |
18 |
# We can only cope with local files
|
|
19 |
if vfs_file.get_uri_scheme() != 'file': |
|
20 |
return
|
|
21 |
||
22 |
file = vfs_file.get_uri() |
|
23 |
try: |
|
24 |
tree, path = WorkingTree.open_containing(file) |
|
25 |
except NotBranchError: |
|
26 |
return
|
|
27 |
||
28 |
tree.add(path) |
|
29 |
||
30 |
return
|
|
31 |
||
32 |
def ignore_cb(self, menu, vfs_file): |
|
33 |
# We can only cope with local files
|
|
34 |
if vfs_file.get_uri_scheme() != 'file': |
|
35 |
return
|
|
36 |
||
37 |
file = vfs_file.get_uri() |
|
38 |
try: |
|
39 |
tree, path = WorkingTree.open_containing(file) |
|
40 |
except NotBranchError: |
|
41 |
return
|
|
42 |
||
0.5.16
by Jelmer Vernooij
Adapt to bzr-gtk's API changes, add 'Clone' dialog |
43 |
#FIXME
|
44 |
||
0.5.4
by jbailey at ubuntu
Add 'add' function. Give framework for other callbacks. |
45 |
return
|
46 |
||
47 |
def unignore_cb(self, menu, vfs_file): |
|
48 |
# We can only cope with local files
|
|
49 |
if vfs_file.get_uri_scheme() != 'file': |
|
50 |
return
|
|
51 |
||
52 |
file = vfs_file.get_uri() |
|
53 |
try: |
|
54 |
tree, path = WorkingTree.open_containing(file) |
|
55 |
except NotBranchError: |
|
56 |
return
|
|
57 |
||
0.5.16
by Jelmer Vernooij
Adapt to bzr-gtk's API changes, add 'Clone' dialog |
58 |
#FIXME
|
59 |
||
0.5.4
by jbailey at ubuntu
Add 'add' function. Give framework for other callbacks. |
60 |
return
|
61 |
||
62 |
def diff_cb(self, menu, vfs_file): |
|
63 |
# We can only cope with local files
|
|
64 |
if vfs_file.get_uri_scheme() != 'file': |
|
65 |
return
|
|
66 |
||
67 |
file = vfs_file.get_uri() |
|
68 |
try: |
|
69 |
tree, path = WorkingTree.open_containing(file) |
|
70 |
except NotBranchError: |
|
71 |
return
|
|
72 |
||
0.5.13
by Jelmer Vernooij
Use the gtk plugin rather than separate bzrk and gannotate |
73 |
from bzrlib.plugins.gtk.viz.diffwin import DiffWindow |
74 |
window = DiffWindow() |
|
87
by Jelmer Vernooij
Fix diff window in nautilus. |
75 |
window.set_diff(tree.branch.nick, tree, tree.branch.basis_tree()) |
0.5.13
by Jelmer Vernooij
Use the gtk plugin rather than separate bzrk and gannotate |
76 |
window.show() |
77 |
||
0.5.4
by jbailey at ubuntu
Add 'add' function. Give framework for other callbacks. |
78 |
return
|
79 |
||
0.5.7
by jbailey at ubuntu
Add hook for creating new bzr trees. |
80 |
def newtree_cb(self, menu, vfs_file): |
81 |
# We can only cope with local files
|
|
82 |
if vfs_file.get_uri_scheme() != 'file': |
|
83 |
return
|
|
84 |
||
85 |
file = vfs_file.get_uri() |
|
86 |
||
87 |
# We only want to continue here if we get a NotBranchError
|
|
88 |
try: |
|
89 |
tree, path = WorkingTree.open_containing(file) |
|
90 |
except NotBranchError: |
|
0.5.9
by jbailey at ubuntu
Implement repository creation |
91 |
BzrDir.create_branch_and_repo(file) |
0.5.7
by jbailey at ubuntu
Add hook for creating new bzr trees. |
92 |
|
0.5.4
by jbailey at ubuntu
Add 'add' function. Give framework for other callbacks. |
93 |
def remove_cb(self, menu, vfs_file): |
94 |
# We can only cope with local files
|
|
95 |
if vfs_file.get_uri_scheme() != 'file': |
|
96 |
return
|
|
97 |
||
98 |
file = vfs_file.get_uri() |
|
99 |
try: |
|
100 |
tree, path = WorkingTree.open_containing(file) |
|
101 |
except NotBranchError: |
|
102 |
return
|
|
103 |
||
0.5.6
by jbailey at ubuntu
Implement remove |
104 |
tree.remove(path) |
105 |
||
0.6.2
by Jelmer Vernooij
Add 'Annotate' menu entry that uses the gannotate bzr plugin |
106 |
def annotate_cb(self, menu, vfs_file): |
107 |
# We can only cope with local files
|
|
108 |
if vfs_file.get_uri_scheme() != 'file': |
|
109 |
return
|
|
110 |
||
111 |
file = vfs_file.get_uri() |
|
112 |
||
113 |
vis = cmd_gannotate() |
|
114 |
vis.run(file) |
|
0.5.16
by Jelmer Vernooij
Adapt to bzr-gtk's API changes, add 'Clone' dialog |
115 |
|
116 |
def clone_cb(self, menu, vfs_file=None): |
|
117 |
# We can only cope with local files
|
|
118 |
if vfs_file.get_uri_scheme() != 'file': |
|
119 |
return
|
|
120 |
||
90
by Jelmer Vernooij
Use Olive's clone dialog in nautilus-bzr; remove the old Clone dialog |
121 |
from bzrlib.plugins.gtk.olive.branch import BranchDialog |
122 |
||
123 |
dialog = BranchDialog(vfs_file.get_name()) |
|
124 |
dialog.display() |
|
0.6.2
by Jelmer Vernooij
Add 'Annotate' menu entry that uses the gannotate bzr plugin |
125 |
|
0.5.15
by Jelmer Vernooij
Add 'Commit' entries |
126 |
def commit_cb(self, menu, vfs_file=None): |
127 |
# We can only cope with local files
|
|
128 |
if vfs_file.get_uri_scheme() != 'file': |
|
129 |
return
|
|
130 |
||
131 |
file = vfs_file.get_uri() |
|
132 |
try: |
|
133 |
tree, path = WorkingTree.open_containing(file) |
|
134 |
except NotBranchError: |
|
135 |
return
|
|
136 |
||
90
by Jelmer Vernooij
Use Olive's clone dialog in nautilus-bzr; remove the old Clone dialog |
137 |
from bzrlib.plugins.gtk.olive.commit import CommitDialog |
138 |
dialog = CommitDialog(tree, path) |
|
139 |
dialog.display() |
|
140 |
gtk.main() |
|
0.6.2
by Jelmer Vernooij
Add 'Annotate' menu entry that uses the gannotate bzr plugin |
141 |
|
0.5.12
by Jelmer Vernooij
Rename "Visualise Bazaar Branch" to "Log", which is a term |
142 |
def log_cb(self, menu, vfs_file): |
0.5.8
by jbailey at ubuntu
Add bzrk plugin |
143 |
# We can only cope with local files
|
144 |
if vfs_file.get_uri_scheme() != 'file': |
|
145 |
return
|
|
146 |
||
147 |
file = vfs_file.get_uri() |
|
148 |
||
149 |
# We only want to continue here if we get a NotBranchError
|
|
150 |
try: |
|
151 |
tree, path = WorkingTree.open_containing(file) |
|
152 |
except NotBranchError: |
|
153 |
return
|
|
154 |
||
155 |
vis = cmd_visualise() |
|
156 |
vis.run(file) |
|
157 |
||
158 |
return
|
|
159 |
||
91.1.4
by Jelmer Vernooij
List pull and merge in nautilus-bzr. |
160 |
def pull_cb(self, menu, vfs_file): |
161 |
# We can only cope with local files
|
|
162 |
if vfs_file.get_uri_scheme() != 'file': |
|
163 |
return
|
|
164 |
||
165 |
file = vfs_file.get_uri() |
|
166 |
||
167 |
# We only want to continue here if we get a NotBranchError
|
|
168 |
try: |
|
169 |
tree, path = WorkingTree.open_containing(file) |
|
170 |
except NotBranchError: |
|
171 |
return
|
|
172 |
||
173 |
from bzrlib.plugins.gtk.olive.pull import PullDialog |
|
174 |
dialog = PullDialog(tree, path) |
|
175 |
dialog.display() |
|
176 |
gtk.main() |
|
177 |
||
178 |
def merge_cb(self, menu, vfs_file): |
|
179 |
# We can only cope with local files
|
|
180 |
if vfs_file.get_uri_scheme() != 'file': |
|
181 |
return
|
|
182 |
||
183 |
file = vfs_file.get_uri() |
|
184 |
||
185 |
# We only want to continue here if we get a NotBranchError
|
|
186 |
try: |
|
187 |
tree, path = WorkingTree.open_containing(file) |
|
188 |
except NotBranchError: |
|
189 |
return
|
|
190 |
||
191 |
from bzrlib.plugins.gtk.olive.merge import MergeDialog |
|
192 |
dialog = MergeDialog(tree, path) |
|
193 |
dialog.display() |
|
194 |
gtk.main() |
|
195 |
||
0.5.7
by jbailey at ubuntu
Add hook for creating new bzr trees. |
196 |
def get_background_items(self, window, vfs_file): |
90
by Jelmer Vernooij
Use Olive's clone dialog in nautilus-bzr; remove the old Clone dialog |
197 |
items = [] |
0.5.7
by jbailey at ubuntu
Add hook for creating new bzr trees. |
198 |
file = vfs_file.get_uri() |
199 |
try: |
|
200 |
tree, path = WorkingTree.open_containing(file) |
|
201 |
except NotBranchError: |
|
202 |
item = nautilus.MenuItem('BzrNautilus::newtree', |
|
91
by Jelmer Vernooij
Some update to TODO. |
203 |
'Make directory versioned', |
0.5.7
by jbailey at ubuntu
Add hook for creating new bzr trees. |
204 |
'Create new Bazaar tree in this folder') |
205 |
item.connect('activate', self.newtree_cb, vfs_file) |
|
0.5.16
by Jelmer Vernooij
Adapt to bzr-gtk's API changes, add 'Clone' dialog |
206 |
items.append(item) |
207 |
||
208 |
item = nautilus.MenuItem('BzrNautilus::clone', |
|
91
by Jelmer Vernooij
Some update to TODO. |
209 |
'Checkout Bazaar branch', |
0.5.16
by Jelmer Vernooij
Adapt to bzr-gtk's API changes, add 'Clone' dialog |
210 |
'Checkout Existing Bazaar Branch') |
211 |
item.connect('activate', self.clone_cb, vfs_file) |
|
212 |
items.append(item) |
|
213 |
||
214 |
return items |
|
0.5.8
by jbailey at ubuntu
Add bzrk plugin |
215 |
|
81
by Jelmer Vernooij
Remove unnecessary "#!/usr/bin/python" shebang lines (fixes #59125). |
216 |
item = nautilus.MenuItem('BzrNautilus::log', |
217 |
'Log', |
|
218 |
'Show Bazaar history') |
|
219 |
item.connect('activate', self.log_cb, vfs_file) |
|
220 |
items.append(item) |
|
0.5.15
by Jelmer Vernooij
Add 'Commit' entries |
221 |
|
91.1.4
by Jelmer Vernooij
List pull and merge in nautilus-bzr. |
222 |
item = nautilus.MenuItem('BzrNautilus::pull', |
223 |
'Pull', |
|
224 |
'Pull from another branch') |
|
225 |
item.connect('activate', self.pull_cb, vfs_file) |
|
226 |
items.append(item) |
|
227 |
||
228 |
item = nautilus.MenuItem('BzrNautilus::merge', |
|
229 |
'Merge', |
|
230 |
'Merge from another branch') |
|
231 |
item.connect('activate', self.merge_cb, vfs_file) |
|
232 |
items.append(item) |
|
233 |
||
81
by Jelmer Vernooij
Remove unnecessary "#!/usr/bin/python" shebang lines (fixes #59125). |
234 |
item = nautilus.MenuItem('BzrNautilus::commit', |
235 |
'Commit', |
|
236 |
'Commit Changes') |
|
237 |
item.connect('activate', self.commit_cb, vfs_file) |
|
238 |
items.append(item) |
|
0.5.15
by Jelmer Vernooij
Add 'Commit' entries |
239 |
|
240 |
return items |
|
0.5.7
by jbailey at ubuntu
Add hook for creating new bzr trees. |
241 |
|
242 |
||
0.5.1
by Jelmer Vernooij
Start working on bzr integration plugin for nautilus |
243 |
def get_file_items(self, window, files): |
244 |
items = [] |
|
0.5.2
by jbailey at ubuntu
Bring this to a state where it actually works. Specifically: |
245 |
|
246 |
for vfs_file in files: |
|
247 |
# We can only cope with local files
|
|
248 |
if vfs_file.get_uri_scheme() != 'file': |
|
249 |
return
|
|
250 |
||
251 |
file = vfs_file.get_uri() |
|
0.5.1
by Jelmer Vernooij
Start working on bzr integration plugin for nautilus |
252 |
try: |
0.5.2
by jbailey at ubuntu
Bring this to a state where it actually works. Specifically: |
253 |
tree, path = WorkingTree.open_containing(file) |
0.5.1
by Jelmer Vernooij
Start working on bzr integration plugin for nautilus |
254 |
except NotBranchError: |
0.5.7
by jbailey at ubuntu
Add hook for creating new bzr trees. |
255 |
if not vfs_file.is_directory(): |
256 |
return
|
|
257 |
item = nautilus.MenuItem('BzrNautilus::newtree', |
|
91
by Jelmer Vernooij
Some update to TODO. |
258 |
'Make directory versioned', |
0.5.7
by jbailey at ubuntu
Add hook for creating new bzr trees. |
259 |
'Create new Bazaar tree in %s' % vfs_file.get_name()) |
260 |
item.connect('activate', self.newtree_cb, vfs_file) |
|
261 |
return item, |
|
0.5.1
by Jelmer Vernooij
Start working on bzr integration plugin for nautilus |
262 |
|
0.5.2
by jbailey at ubuntu
Bring this to a state where it actually works. Specifically: |
263 |
file_class = tree.file_class(path) |
264 |
||
265 |
if file_class == '?': |
|
266 |
item = nautilus.MenuItem('BzrNautilus::add', |
|
267 |
'Add', |
|
268 |
'Add as versioned file') |
|
269 |
item.connect('activate', self.add_cb, vfs_file) |
|
270 |
items.append(item) |
|
271 |
||
272 |
item = nautilus.MenuItem('BzrNautilus::ignore', |
|
273 |
'Ignore', |
|
274 |
'Ignore file for versioning') |
|
275 |
item.connect('activate', self.ignore_cb, vfs_file) |
|
276 |
items.append(item) |
|
277 |
elif file_class == 'I': |
|
278 |
item = nautilus.MenuItem('BzrNautilus::unignore', |
|
279 |
'Unignore', |
|
280 |
'Unignore file for versioning') |
|
281 |
item.connect('activate', self.unignore_cb, vfs_file) |
|
282 |
items.append(item) |
|
283 |
elif file_class == 'V': |
|
81
by Jelmer Vernooij
Remove unnecessary "#!/usr/bin/python" shebang lines (fixes #59125). |
284 |
item = nautilus.MenuItem('BzrNautilus::log', |
285 |
'Log', |
|
286 |
'List changes') |
|
287 |
item.connect('activate', self.log_cb, vfs_file) |
|
288 |
items.append(item) |
|
0.5.2
by jbailey at ubuntu
Bring this to a state where it actually works. Specifically: |
289 |
|
81
by Jelmer Vernooij
Remove unnecessary "#!/usr/bin/python" shebang lines (fixes #59125). |
290 |
item = nautilus.MenuItem('BzrNautilus::diff', |
291 |
'Diff', |
|
292 |
'Show differences') |
|
293 |
item.connect('activate', self.diff_cb, vfs_file) |
|
294 |
items.append(item) |
|
0.5.2
by jbailey at ubuntu
Bring this to a state where it actually works. Specifically: |
295 |
|
296 |
item = nautilus.MenuItem('BzrNautilus::remove', |
|
297 |
'Remove', |
|
298 |
'Remove this file from versioning') |
|
299 |
item.connect('activate', self.remove_cb, vfs_file) |
|
300 |
items.append(item) |
|
0.6.2
by Jelmer Vernooij
Add 'Annotate' menu entry that uses the gannotate bzr plugin |
301 |
|
81
by Jelmer Vernooij
Remove unnecessary "#!/usr/bin/python" shebang lines (fixes #59125). |
302 |
item = nautilus.MenuItem('BzrNautilus::annotate', |
303 |
'Annotate', |
|
304 |
'Annotate File Data') |
|
305 |
item.connect('activate', self.annotate_cb, vfs_file) |
|
306 |
items.append(item) |
|
307 |
||
308 |
item = nautilus.MenuItem('BzrNautilus::commit', |
|
309 |
'Commit', |
|
310 |
'Commit Changes') |
|
311 |
item.connect('activate', self.commit_cb, vfs_file) |
|
312 |
items.append(item) |
|
313 |
||
0.5.1
by Jelmer Vernooij
Start working on bzr integration plugin for nautilus |
314 |
return items |
88
by Jelmer Vernooij
Show column with file status. |
315 |
|
316 |
def get_columns(self): |
|
317 |
return nautilus.Column("BzrNautilus::bzr_status", |
|
318 |
"bzr_status", |
|
319 |
"Bzr Status", |
|
320 |
"Version control status"), |
|
321 |
||
322 |
def update_file_info(self, file): |
|
323 |
if file.get_uri_scheme() != 'file': |
|
324 |
return
|
|
325 |
||
326 |
try: |
|
327 |
tree, path = WorkingTree.open_containing(file.get_uri()) |
|
328 |
except NotBranchError: |
|
329 |
return
|
|
330 |
||
331 |
emblem = None |
|
332 |
status = None |
|
333 |
||
334 |
if tree.has_filename(path): |
|
335 |
emblem = 'cvs-controlled' |
|
336 |
status = 'unchanged' |
|
337 |
id = tree.path2id(path) |
|
338 |
||
339 |
delta = tree.changes_from(tree.branch.basis_tree()) |
|
340 |
if delta.touches_file_id(id): |
|
341 |
emblem = 'cvs-modified' |
|
342 |
status = 'modified' |
|
343 |
for f, _, _ in delta.added: |
|
344 |
if f == path: |
|
345 |
emblem = 'cvs-added' |
|
346 |
status = 'added' |
|
347 |
||
348 |
for of, f, _, _, _, _ in delta.renamed: |
|
349 |
if f == path: |
|
350 |
status = 'renamed from %s' % f |
|
351 |
||
352 |
elif tree.branch.basis_tree().has_filename(path): |
|
353 |
emblem = 'cvs-removed' |
|
354 |
status = 'removed' |
|
355 |
else: |
|
356 |
# FIXME: Check for ignored files
|
|
357 |
status = 'unversioned' |
|
358 |
||
359 |
if emblem is not None: |
|
360 |
file.add_emblem(emblem) |
|
361 |
file.add_string_attribute('bzr_status', status) |