bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
1 |
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
2 |
#
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
7 |
#
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
12 |
#
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
import sys |
|
18 |
||
19 |
try: |
|
20 |
import pygtk |
|
21 |
pygtk.require("2.0") |
|
22 |
except: |
|
23 |
pass
|
|
24 |
try: |
|
25 |
import gtk |
|
26 |
import gtk.glade |
|
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
27 |
import gobject |
0.8.26
by Szilveszter Farkas (Phanatic)
Implemented Diff window; added menu.py (was missing from last commit) |
28 |
import pango |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
29 |
except: |
30 |
sys.exit(1) |
|
31 |
||
0.8.26
by Szilveszter Farkas (Phanatic)
Implemented Diff window; added menu.py (was missing from last commit) |
32 |
import bzrlib |
33 |
||
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
34 |
if bzrlib.version_info < (0, 9): |
0.8.26
by Szilveszter Farkas (Phanatic)
Implemented Diff window; added menu.py (was missing from last commit) |
35 |
# function deprecated after 0.9
|
36 |
from bzrlib.delta import compare_trees |
|
37 |
||
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
38 |
import bzrlib.errors as errors |
39 |
from bzrlib.workingtree import WorkingTree |
|
40 |
||
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
41 |
class OliveCommit: |
42 |
""" Display Commit dialog and perform the needed actions. """ |
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
43 |
def __init__(self, gladefile, comm, dialog): |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
44 |
""" Initialize the Commit dialog. """ |
45 |
self.gladefile = gladefile |
|
46 |
self.glade = gtk.glade.XML(self.gladefile, 'window_commit') |
|
47 |
||
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
48 |
# Communication object
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
49 |
self.comm = comm |
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
50 |
# Dialog object
|
51 |
self.dialog = dialog |
|
52 |
||
53 |
# Get the Commit dialog widget
|
|
54 |
self.window = self.glade.get_widget('window_commit') |
|
55 |
||
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
56 |
# Check if current location is a branch
|
57 |
try: |
|
58 |
(self.wt, path) = WorkingTree.open_containing(self.comm.get_path()) |
|
59 |
branch = self.wt.branch |
|
60 |
except errors.NotBranchError: |
|
61 |
self.notbranch = True |
|
62 |
return
|
|
63 |
except: |
|
64 |
raise
|
|
65 |
||
66 |
file_id = self.wt.path2id(path) |
|
67 |
||
68 |
self.notbranch = False |
|
69 |
if file_id is None: |
|
70 |
self.notbranch = True |
|
71 |
return
|
|
72 |
||
73 |
# Set the delta
|
|
74 |
self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision()) |
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
75 |
if bzrlib.version_info < (0, 9): |
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
76 |
self.delta = compare_trees(self.old_tree, self.wt) |
77 |
else: |
|
78 |
self.delta = self.wt.changes_from(self.old_tree) |
|
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
79 |
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
80 |
# Dictionary for signal_autoconnect
|
81 |
dic = { "on_button_commit_commit_clicked": self.commit, |
|
82 |
"on_button_commit_cancel_clicked": self.close } |
|
83 |
||
84 |
# Connect the signals to the handlers
|
|
85 |
self.glade.signal_autoconnect(dic) |
|
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
86 |
|
87 |
# Create the file list
|
|
88 |
self._create_file_view() |
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
89 |
|
90 |
# Some additional widgets
|
|
91 |
self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local') |
|
0.8.26
by Szilveszter Farkas (Phanatic)
Implemented Diff window; added menu.py (was missing from last commit) |
92 |
self.textview = self.glade.get_widget('textview_commit') |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
93 |
|
94 |
def display(self): |
|
95 |
""" Display the Push dialog. """ |
|
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
96 |
if self.notbranch: |
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
97 |
self.dialog.error_dialog('Directory is not a branch', |
98 |
'You can perform this action only in a branch.') |
|
99 |
self.close() |
|
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
100 |
else: |
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
101 |
from olive.backend.info import is_checkout |
102 |
if is_checkout(self.comm.get_path()): |
|
103 |
# we have a checkout, so the local commit checkbox must appear
|
|
104 |
self.checkbutton_local.show() |
|
105 |
||
0.8.26
by Szilveszter Farkas (Phanatic)
Implemented Diff window; added menu.py (was missing from last commit) |
106 |
self.textview.modify_font(pango.FontDescription("Monospace")) |
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
107 |
self.window.show() |
108 |
||
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
109 |
|
110 |
# This code is from Jelmer Vernooij's bzr-gtk branch
|
|
111 |
def _create_file_view(self): |
|
0.8.21
by Szilveszter Farkas (Phanatic)
2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
112 |
self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN, |
113 |
gobject.TYPE_STRING, |
|
114 |
gobject.TYPE_STRING) |
|
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
115 |
self.file_view = self.glade.get_widget('treeview_commit_select') |
116 |
self.file_view.set_model(self.file_store) |
|
117 |
crt = gtk.CellRendererToggle() |
|
118 |
crt.set_property("activatable", True) |
|
119 |
crt.connect("toggled", self._toggle_commit, self.file_store) |
|
0.8.21
by Szilveszter Farkas (Phanatic)
2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
120 |
self.file_view.append_column(gtk.TreeViewColumn("Commit", |
121 |
crt, active=0)) |
|
122 |
self.file_view.append_column(gtk.TreeViewColumn("Path", |
|
123 |
gtk.CellRendererText(), text=1)) |
|
124 |
self.file_view.append_column(gtk.TreeViewColumn("Type", |
|
125 |
gtk.CellRendererText(), text=2)) |
|
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
126 |
|
0.8.21
by Szilveszter Farkas (Phanatic)
2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
127 |
for path, _, _ in self.delta.added: |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
128 |
self.file_store.append([ True, path, "added" ]) |
129 |
||
0.8.21
by Szilveszter Farkas (Phanatic)
2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
130 |
for path, _, _ in self.delta.removed: |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
131 |
self.file_store.append([ True, path, "removed" ]) |
132 |
||
0.8.21
by Szilveszter Farkas (Phanatic)
2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
133 |
for oldpath, _, _, _, _, _ in self.delta.renamed: |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
134 |
self.file_store.append([ True, oldpath, "renamed"]) |
135 |
||
0.8.21
by Szilveszter Farkas (Phanatic)
2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
136 |
for path, _, _, _, _ in self.delta.modified: |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
137 |
self.file_store.append([ True, path, "modified"]) |
138 |
||
139 |
def _get_specific_files(self): |
|
140 |
ret = [] |
|
141 |
it = self.file_store.get_iter_first() |
|
142 |
while it: |
|
143 |
if self.file_store.get_value(it, 0): |
|
0.8.21
by Szilveszter Farkas (Phanatic)
2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
144 |
ret.append(self.file_store.get_value(it, 1)) |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
145 |
it = self.file_store.iter_next(it) |
146 |
||
147 |
return ret |
|
148 |
# end of bzr-gtk code
|
|
149 |
||
150 |
def _toggle_commit(self, cell, path, model): |
|
151 |
model[path][0] = not model[path][0] |
|
152 |
return
|
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
153 |
|
154 |
def commit(self, widget): |
|
0.8.26
by Szilveszter Farkas (Phanatic)
Implemented Diff window; added menu.py (was missing from last commit) |
155 |
textbuffer = self.textview.get_buffer() |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
156 |
start, end = textbuffer.get_bounds() |
157 |
message = textbuffer.get_text(start, end) |
|
158 |
||
159 |
checkbutton_strict = self.glade.get_widget('checkbutton_commit_strict') |
|
160 |
checkbutton_force = self.glade.get_widget('checkbutton_commit_force') |
|
161 |
||
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
162 |
specific_files = self._get_specific_files() |
163 |
||
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
164 |
self.comm.set_busy(self.window) |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
165 |
# merged from Jelmer Vernooij's olive integration branch
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
166 |
try: |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
167 |
self.wt.commit(message, |
168 |
allow_pointless=checkbutton_force.get_active(), |
|
169 |
strict=checkbutton_strict.get_active(), |
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
170 |
local=self.checkbutton_local.get_active(), |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
171 |
specific_files=specific_files) |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
172 |
except errors.NotBranchError: |
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
173 |
self.dialog.error_dialog('Directory is not a branch', |
174 |
'You can perform this action only in a branch.') |
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
175 |
self.comm.set_busy(self.window, False) |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
176 |
return
|
177 |
except errors.LocalRequiresBoundBranch: |
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
178 |
self.dialog.error_dialog('Directory is not a checkout', |
179 |
'You can perform local commit only on checkouts.') |
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
180 |
self.comm.set_busy(self.window, False) |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
181 |
return
|
182 |
except errors.PointlessCommit: |
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
183 |
self.dialog.error_dialog('No changes to commit', |
184 |
'Try force commit if you want to commit anyway.') |
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
185 |
self.comm.set_busy(self.window, False) |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
186 |
return
|
187 |
except errors.ConflictsInTree: |
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
188 |
self.dialog.error_dialog('Conflicts in tree' |
189 |
'You need to resolve the conflicts before committing.') |
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
190 |
self.comm.set_busy(self.window, False) |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
191 |
return
|
192 |
except errors.StrictCommitFailed: |
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
193 |
self.dialog.error_dialog('Strict commit failed' |
194 |
'There are unknown files in the working tree.\nPlease add or delete them.') |
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
195 |
self.comm.set_busy(self.window, False) |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
196 |
return
|
197 |
except errors.BoundBranchOutOfDate, errmsg: |
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
198 |
self.dialog.error_dialog('Bound branch is out of date', |
199 |
'%s' % errmsg) |
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
200 |
self.comm.set_busy(self.window, False) |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
201 |
return
|
202 |
except: |
|
203 |
raise
|
|
204 |
||
205 |
self.close() |
|
206 |
self.comm.refresh_right() |
|
207 |
||
208 |
def close(self, widget=None): |
|
209 |
self.window.destroy() |