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.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
32 |
from bzrlib import version_info |
0.8.26
by Szilveszter Farkas (Phanatic)
Implemented Diff window; added menu.py (was missing from last commit) |
33 |
|
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
34 |
import bzrlib.errors as errors |
35 |
from bzrlib.workingtree import WorkingTree |
|
36 |
||
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
37 |
class OliveCommit: |
38 |
""" Display Commit dialog and perform the needed actions. """ |
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
39 |
def __init__(self, gladefile, comm, dialog): |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
40 |
""" Initialize the Commit dialog. """ |
41 |
self.gladefile = gladefile |
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
42 |
self.glade = gtk.glade.XML(self.gladefile, 'window_commit', 'olive-gtk') |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
43 |
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
44 |
# Communication object
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
45 |
self.comm = comm |
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
46 |
# Dialog object
|
47 |
self.dialog = dialog |
|
48 |
||
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
49 |
# Get some important widgets
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
50 |
self.window = self.glade.get_widget('window_commit') |
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
51 |
self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local') |
52 |
self.textview = self.glade.get_widget('textview_commit') |
|
53 |
self.file_view = self.glade.get_widget('treeview_commit_select') |
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
54 |
|
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
55 |
# Check if current location is a branch
|
56 |
try: |
|
57 |
(self.wt, path) = WorkingTree.open_containing(self.comm.get_path()) |
|
58 |
branch = self.wt.branch |
|
59 |
except errors.NotBranchError: |
|
60 |
self.notbranch = True |
|
61 |
return
|
|
62 |
except: |
|
63 |
raise
|
|
64 |
||
65 |
file_id = self.wt.path2id(path) |
|
66 |
||
67 |
self.notbranch = False |
|
68 |
if file_id is None: |
|
69 |
self.notbranch = True |
|
70 |
return
|
|
71 |
||
72 |
# Set the delta
|
|
73 |
self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision()) |
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
74 |
if version_info < (0, 9): |
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
75 |
self.delta = compare_trees(self.old_tree, self.wt) |
76 |
else: |
|
77 |
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> |
78 |
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
79 |
# Dictionary for signal_autoconnect
|
80 |
dic = { "on_button_commit_commit_clicked": self.commit, |
|
81 |
"on_button_commit_cancel_clicked": self.close } |
|
82 |
||
83 |
# Connect the signals to the handlers
|
|
84 |
self.glade.signal_autoconnect(dic) |
|
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
85 |
|
86 |
# Create the file list
|
|
87 |
self._create_file_view() |
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
88 |
|
89 |
def display(self): |
|
90 |
""" Display the Push dialog. """ |
|
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
91 |
if self.notbranch: |
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
92 |
self.dialog.error_dialog(_('Directory is not a branch'), |
93 |
_('You can perform this action only in a branch.')) |
|
0.8.46
by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups. |
94 |
self.close() |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
95 |
else: |
0.11.11
by Jelmer Vernooij
Fix a few more bits that I broke earlier. |
96 |
from bzrlib.branch import Branch |
0.11.9
by Jelmer Vernooij
Remove last few bits from backend and integrate them where necessary. |
97 |
branch = Branch.open_containing(self.comm.get_path())[0] |
98 |
||
99 |
if branch.get_bound_location() is not None: |
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
100 |
# we have a checkout, so the local commit checkbox must appear
|
101 |
self.checkbutton_local.show() |
|
102 |
||
0.8.26
by Szilveszter Farkas (Phanatic)
Implemented Diff window; added menu.py (was missing from last commit) |
103 |
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 |
104 |
self.window.show() |
105 |
||
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
106 |
|
107 |
# This code is from Jelmer Vernooij's bzr-gtk branch
|
|
108 |
def _create_file_view(self): |
|
0.8.21
by Szilveszter Farkas (Phanatic)
2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
109 |
self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN, |
110 |
gobject.TYPE_STRING, |
|
111 |
gobject.TYPE_STRING) |
|
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
112 |
self.file_view.set_model(self.file_store) |
113 |
crt = gtk.CellRendererToggle() |
|
114 |
crt.set_property("activatable", True) |
|
115 |
crt.connect("toggled", self._toggle_commit, self.file_store) |
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
116 |
self.file_view.append_column(gtk.TreeViewColumn(_('Commit'), |
0.8.21
by Szilveszter Farkas (Phanatic)
2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
117 |
crt, active=0)) |
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
118 |
self.file_view.append_column(gtk.TreeViewColumn(_('Path'), |
0.8.21
by Szilveszter Farkas (Phanatic)
2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
119 |
gtk.CellRendererText(), text=1)) |
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
120 |
self.file_view.append_column(gtk.TreeViewColumn(_('Type'), |
0.8.21
by Szilveszter Farkas (Phanatic)
2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
121 |
gtk.CellRendererText(), text=2)) |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
122 |
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
123 |
for path, id, kind in self.delta.added: |
124 |
self.file_store.append([ True, path, _('added') ]) |
|
125 |
||
126 |
for path, id, kind in self.delta.removed: |
|
127 |
self.file_store.append([ True, path, _('removed') ]) |
|
128 |
||
129 |
for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed: |
|
130 |
self.file_store.append([ True, oldpath, _('renamed') ]) |
|
131 |
||
132 |
for path, id, kind, text_modified, meta_modified in self.delta.modified: |
|
133 |
self.file_store.append([ True, path, _('modified') ]) |
|
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
134 |
|
135 |
def _get_specific_files(self): |
|
136 |
ret = [] |
|
137 |
it = self.file_store.get_iter_first() |
|
138 |
while it: |
|
139 |
if self.file_store.get_value(it, 0): |
|
0.8.21
by Szilveszter Farkas (Phanatic)
2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
140 |
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> |
141 |
it = self.file_store.iter_next(it) |
142 |
||
143 |
return ret |
|
144 |
# end of bzr-gtk code
|
|
145 |
||
146 |
def _toggle_commit(self, cell, path, model): |
|
147 |
model[path][0] = not model[path][0] |
|
148 |
return
|
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
149 |
|
150 |
def commit(self, widget): |
|
0.8.26
by Szilveszter Farkas (Phanatic)
Implemented Diff window; added menu.py (was missing from last commit) |
151 |
textbuffer = self.textview.get_buffer() |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
152 |
start, end = textbuffer.get_bounds() |
153 |
message = textbuffer.get_text(start, end) |
|
154 |
||
155 |
checkbutton_strict = self.glade.get_widget('checkbutton_commit_strict') |
|
156 |
checkbutton_force = self.glade.get_widget('checkbutton_commit_force') |
|
157 |
||
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
158 |
specific_files = self._get_specific_files() |
159 |
||
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
160 |
self.comm.set_busy(self.window) |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
161 |
# merged from Jelmer Vernooij's olive integration branch
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
162 |
try: |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
163 |
self.wt.commit(message, |
164 |
allow_pointless=checkbutton_force.get_active(), |
|
165 |
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 |
166 |
local=self.checkbutton_local.get_active(), |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
167 |
specific_files=specific_files) |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
168 |
except errors.NotBranchError: |
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
169 |
self.dialog.error_dialog(_('Directory is not a branch'), |
170 |
_('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 |
171 |
self.comm.set_busy(self.window, False) |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
172 |
return
|
173 |
except errors.LocalRequiresBoundBranch: |
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
174 |
self.dialog.error_dialog(_('Directory is not a checkout'), |
175 |
_('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 |
176 |
self.comm.set_busy(self.window, False) |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
177 |
return
|
178 |
except errors.PointlessCommit: |
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
179 |
self.dialog.error_dialog(_('No changes to commit'), |
180 |
_('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 |
181 |
self.comm.set_busy(self.window, False) |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
182 |
return
|
183 |
except errors.ConflictsInTree: |
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
184 |
self.dialog.error_dialog(_('Conflicts in tree'), |
185 |
_('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 |
186 |
self.comm.set_busy(self.window, False) |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
187 |
return
|
188 |
except errors.StrictCommitFailed: |
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
189 |
self.dialog.error_dialog(_('Strict commit failed'), |
190 |
_('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 |
191 |
self.comm.set_busy(self.window, False) |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
192 |
return
|
193 |
except errors.BoundBranchOutOfDate, errmsg: |
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
194 |
self.dialog.error_dialog(_('Bound branch is out of date'), |
195 |
_('%s') % errmsg) |
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
196 |
self.comm.set_busy(self.window, False) |
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
197 |
return
|
198 |
except: |
|
199 |
raise
|
|
200 |
||
201 |
self.close() |
|
202 |
self.comm.refresh_right() |
|
203 |
||
204 |
def close(self, widget=None): |
|
205 |
self.window.destroy() |