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 |
try: |
|
18 |
import pygtk |
|
19 |
pygtk.require("2.0") |
|
20 |
except: |
|
21 |
pass
|
|
0.8.98
by Szilveszter Farkas (Phanatic)
Loads of fixes. Pyflakes cleanup. |
22 |
|
0.13.11
by Jelmer Vernooij
Bunch of small fixes, cleanups and simplifications. |
23 |
import gtk |
24 |
import gobject |
|
25 |
import pango |
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
26 |
|
126.1.10
by Szilveszter Farkas (Phanatic)
Allow to commit single files from the context menu (Fixed: #54983) |
27 |
import os.path |
278.1.5
by John Arbash Meinel
Starting to flesh out the dialog with actual windows. |
28 |
import re |
126.1.10
by Szilveszter Farkas (Phanatic)
Allow to commit single files from the context menu (Fixed: #54983) |
29 |
|
248
by Jelmer Vernooij
Merge fixes for #127392 and #127381) |
30 |
from bzrlib import errors, osutils |
235.1.5
by Mateusz Korniak
Missing mutter import added. |
31 |
from bzrlib.trace import mutter |
0.8.20
by Szilveszter Farkas (Phanatic)
2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
32 |
|
153
by Jelmer Vernooij
Fix references to dialog. |
33 |
from dialog import error_dialog, question_dialog |
132
by Jelmer Vernooij
Use decorator for catching and showing bzr-gtk errors graphically. Eventually, this should go away and should be handled by the ui factory. |
34 |
from errors import show_bzr_error |
93.1.6
by Alexander Belchenko
detecting name of glade file doing in separate module (olive.gladefile) |
35 |
|
158
by Jelmer Vernooij
If available, use NetworkManager to find out whether a commit should be local or not. |
36 |
try: |
37 |
import dbus |
|
38 |
import dbus.glib |
|
180
by Jelmer Vernooij
Don't obtain handle to network manager until it's actually needed. |
39 |
have_dbus = True |
158
by Jelmer Vernooij
If available, use NetworkManager to find out whether a commit should be local or not. |
40 |
except ImportError: |
180
by Jelmer Vernooij
Don't obtain handle to network manager until it's actually needed. |
41 |
have_dbus = False |
158
by Jelmer Vernooij
If available, use NetworkManager to find out whether a commit should be local or not. |
42 |
|
278.1.4
by John Arbash Meinel
Just playing around. |
43 |
|
278.1.5
by John Arbash Meinel
Starting to flesh out the dialog with actual windows. |
44 |
def pending_revisions(wt): |
45 |
"""Return a list of pending merges or None if there are none of them. |
|
46 |
||
47 |
Arguably this should be a core function, and
|
|
48 |
``bzrlib.status.show_pending_merges`` should be built on top of it.
|
|
49 |
||
50 |
:return: [(rev, [children])]
|
|
51 |
"""
|
|
52 |
parents = wt.get_parent_ids() |
|
53 |
if len(parents) < 2: |
|
54 |
return None |
|
55 |
||
56 |
# The basic pending merge algorithm uses the same algorithm as
|
|
57 |
# bzrlib.status.show_pending_merges
|
|
58 |
pending = parents[1:] |
|
59 |
branch = wt.branch |
|
60 |
last_revision = parents[0] |
|
61 |
||
62 |
if last_revision is not None: |
|
63 |
try: |
|
64 |
ignore = set(branch.repository.get_ancestry(last_revision, |
|
65 |
topo_sorted=False)) |
|
66 |
except errors.NoSuchRevision: |
|
67 |
# the last revision is a ghost : assume everything is new
|
|
68 |
# except for it
|
|
69 |
ignore = set([None, last_revision]) |
|
70 |
else: |
|
71 |
ignore = set([None]) |
|
72 |
||
73 |
pm = [] |
|
74 |
for merge in pending: |
|
75 |
ignore.add(merge) |
|
76 |
try: |
|
77 |
rev = branch.repository.get_revision(merge) |
|
78 |
children = [] |
|
79 |
pm.append((rev, children)) |
|
80 |
||
81 |
# This does need to be topo sorted, so we search backwards
|
|
82 |
inner_merges = branch.repository.get_ancestry(merge) |
|
83 |
assert inner_merges[0] is None |
|
84 |
inner_merges.pop(0) |
|
85 |
for mmerge in reversed(inner_merges): |
|
86 |
if mmerge in ignore: |
|
87 |
continue
|
|
88 |
rev = branch.repository.get_revision(mmerge) |
|
89 |
children.append(rev) |
|
90 |
||
91 |
ignore.add(mmerge) |
|
92 |
except errors.NoSuchRevision: |
|
93 |
print "DEBUG: NoSuchRevision:", merge |
|
94 |
||
95 |
return pm |
|
96 |
||
97 |
||
135
by Jelmer Vernooij
Throw out the old CommitDialog code and use the new code instead, also for 'gcommit'. |
98 |
class CommitDialog(gtk.Dialog): |
278.1.5
by John Arbash Meinel
Starting to flesh out the dialog with actual windows. |
99 |
"""Implementation of Commit.""" |
100 |
||
101 |
def __init__(self, wt, selected=None, parent=None): |
|
102 |
gtk.Dialog.__init__(self, title="Commit - Olive", |
|
103 |
parent=parent, |
|
104 |
flags=0, |
|
105 |
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) |
|
106 |
self._wt = wt |
|
107 |
self._selected = selected |
|
108 |
||
109 |
self.setup_params() |
|
110 |
self.construct() |
|
111 |
self.set_default_size(800, 600) |
|
112 |
||
113 |
def setup_params(self): |
|
114 |
"""Setup the member variables for state.""" |
|
115 |
self._basis_tree = self._wt.basis_tree() |
|
116 |
self._delta = self._wt.changes_from(self._basis_tree) |
|
117 |
||
118 |
self._pending = pending_revisions(self._wt) |
|
119 |
||
120 |
self._is_checkout = (self._wt.branch.get_bound_location() is not None) |
|
121 |
||
122 |
def construct(self): |
|
123 |
"""Build up the dialog widgets.""" |
|
124 |
# The primary pane which splits it into left and right (adjustable)
|
|
125 |
# sections.
|
|
278.1.4
by John Arbash Meinel
Just playing around. |
126 |
self._hpane = gtk.HPaned() |
278.1.5
by John Arbash Meinel
Starting to flesh out the dialog with actual windows. |
127 |
|
128 |
self._construct_left_pane() |
|
129 |
self._construct_right_pane() |
|
130 |
||
131 |
self.vbox.pack_start(self._hpane) |
|
132 |
self._hpane.show() |
|
133 |
self.set_focus(self._global_message_text_view) |
|
134 |
||
135 |
def _construct_left_pane(self): |
|
136 |
self._left_pane_box = gtk.VBox(homogeneous=False, spacing=3) |
|
137 |
self._construct_file_list() |
|
138 |
self._construct_pending_list() |
|
139 |
||
140 |
self._pending_box.show() |
|
141 |
self._hpane.pack1(self._left_pane_box, resize=False, shrink=True) |
|
142 |
self._left_pane_box.show() |
|
143 |
||
144 |
def _construct_right_pane(self): |
|
145 |
# TODO: I really want to make it so the diff view gets more space than
|
|
146 |
# the global commit message, and the per-file commit message gets even
|
|
147 |
# less. When I did it with wxGlade, I set it to 4 for diff, 2 for
|
|
148 |
# commit, and 1 for file commit, and it looked good. But I don't seem
|
|
149 |
# to have a way to do that with the gtk boxes... :( (Which is extra
|
|
150 |
# weird since wx uses gtk on Linux...)
|
|
151 |
self._right_pane_box = gtk.VBox(homogeneous=False, spacing=3) |
|
152 |
self._construct_diff_view() |
|
153 |
self._construct_file_message() |
|
154 |
self._construct_global_message() |
|
155 |
||
156 |
self._right_pane_box.show() |
|
157 |
self._hpane.pack2(self._right_pane_box, resize=True, shrink=True) |
|
158 |
||
159 |
def _construct_file_list(self): |
|
160 |
self._files_box = gtk.VBox() |
|
161 |
file_label = gtk.Label() |
|
162 |
file_label.set_markup(_('<b>Files</b>')) |
|
163 |
file_label.show() |
|
164 |
self._files_box.pack_start(file_label, expand=False) |
|
165 |
||
166 |
scroller = gtk.ScrolledWindow() |
|
167 |
scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
|
126.1.1
by Szilveszter Farkas (Phanatic)
New Commit dialog implementation (no more Glade). |
168 |
self._treeview_files = gtk.TreeView() |
278.1.5
by John Arbash Meinel
Starting to flesh out the dialog with actual windows. |
169 |
self._treeview_files.show() |
170 |
scroller.add(self._treeview_files) |
|
171 |
scroller.show() |
|
172 |
scroller.set_shadow_type(gtk.SHADOW_IN) |
|
173 |
self._files_box.pack_start(scroller, |
|
174 |
expand=True, fill=True) |
|
175 |
self._files_box.show() |
|
176 |
self._left_pane_box.pack_start(self._files_box) |
|
177 |
||
178 |
def _construct_pending_list(self): |
|
179 |
# Pending information defaults to hidden, we put it all in 1 box, so
|
|
180 |
# that we can show/hide all of them at once
|
|
181 |
self._pending_box = gtk.VBox() |
|
182 |
self._pending_box.hide() |
|
183 |
||
184 |
# TODO: This message should be centered
|
|
185 |
pending_message = gtk.Label() |
|
186 |
pending_message.set_markup( |
|
187 |
_('<i>Cannot select specific files when merging</i>')) |
|
188 |
self._pending_box.pack_start(pending_message, expand=False) |
|
189 |
pending_message.show() |
|
190 |
||
191 |
pending_label = gtk.Label() |
|
192 |
pending_label.set_markup(_('<b>Pending Revisions</b>')) |
|
193 |
self._pending_box.pack_start(pending_label, expand=False) |
|
194 |
pending_label.show() |
|
195 |
||
196 |
scroller = gtk.ScrolledWindow() |
|
197 |
scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
|
198 |
self._treeview_pending = gtk.TreeView() |
|
199 |
scroller.add(self._treeview_pending) |
|
200 |
scroller.show() |
|
201 |
scroller.set_shadow_type(gtk.SHADOW_IN) |
|
202 |
self._pending_box.pack_start(scroller, |
|
203 |
expand=True, fill=True) |
|
204 |
self._treeview_pending.show() |
|
205 |
self._left_pane_box.pack_start(self._pending_box) |
|
206 |
||
207 |
def _construct_diff_view(self): |
|
208 |
from diff import DiffDisplay |
|
209 |
||
210 |
self._diff_label = gtk.Label(_('Diff for whole tree')) |
|
211 |
self._right_pane_box.pack_start(self._diff_label, expand=False) |
|
212 |
self._diff_label.show() |
|
213 |
||
214 |
self._diff_view = DiffDisplay() |
|
215 |
# self._diff_display.set_trees(self.wt, self.wt.basis_tree())
|
|
216 |
# self._diff_display.show_diff(None)
|
|
217 |
self._right_pane_box.pack_start(self._diff_view, |
|
218 |
expand=True, fill=True) |
|
219 |
self._diff_view.show() |
|
220 |
||
221 |
def _construct_file_message(self): |
|
222 |
file_message_box = gtk.VBox() |
|
223 |
self._file_message_text_view = gtk.TextView() |
|
224 |
# There should be some way to get at the TextView's ScrolledWindow
|
|
225 |
file_message_box.pack_start(self._file_message_text_view, expand=True, fill=True) |
|
226 |
||
227 |
self._file_message_text_view.modify_font(pango.FontDescription("Monospace")) |
|
228 |
self._file_message_text_view.set_wrap_mode(gtk.WRAP_WORD) |
|
229 |
self._file_message_text_view.set_accepts_tab(False) |
|
230 |
self._file_message_text_view.show() |
|
231 |
||
232 |
self._file_message_expander = gtk.Expander(_('Message for XXX')) |
|
233 |
self._file_message_expander.add(file_message_box) |
|
234 |
file_message_box.show() |
|
278.1.6
by John Arbash Meinel
Clarify the note on the file message expander. |
235 |
# When expanded, we want to change expand=True, so that the message box
|
236 |
# gets more space. But when it is shrunk, it has nothing to do with
|
|
237 |
# that space, so we start it at expand=False
|
|
278.1.5
by John Arbash Meinel
Starting to flesh out the dialog with actual windows. |
238 |
self._right_pane_box.pack_start(self._file_message_expander, |
239 |
expand=False, fill=True) |
|
240 |
self._file_message_expander.connect('notify::expanded', |
|
241 |
self._expand_file_message_callback) |
|
242 |
self._file_message_expander.show() |
|
243 |
||
244 |
def _expand_file_message_callback(self, expander, param_spec): |
|
245 |
if expander.get_expanded(): |
|
246 |
self._right_pane_box.set_child_packing(expander, |
|
247 |
expand=True, fill=True, padding=0, pack_type=gtk.PACK_START) |
|
248 |
else: |
|
249 |
self._right_pane_box.set_child_packing(expander, |
|
250 |
expand=False, fill=True, padding=0, pack_type=gtk.PACK_START) |
|
251 |
||
252 |
def _construct_global_message(self): |
|
253 |
self._global_message_label = gtk.Label(_('Global Commit Message')) |
|
254 |
self._right_pane_box.pack_start(self._global_message_label, expand=False) |
|
255 |
self._global_message_label.show() |
|
256 |
||
257 |
self._global_message_text_view = gtk.TextView() |
|
258 |
self._global_message_text_view.modify_font(pango.FontDescription("Monospace")) |
|
259 |
self._right_pane_box.pack_start(self._global_message_text_view, |
|
260 |
expand=True, fill=True) |
|
261 |
self._file_message_text_view.set_wrap_mode(gtk.WRAP_WORD) |
|
262 |
self._file_message_text_view.set_accepts_tab(False) |
|
263 |
self._global_message_text_view.show() |
|
264 |
||
265 |
@staticmethod
|
|
266 |
def _rev_to_pending_info(rev): |
|
267 |
"""Get the information from a pending merge.""" |
|
126.1.1
by Szilveszter Farkas (Phanatic)
New Commit dialog implementation (no more Glade). |
268 |
from bzrlib.osutils import format_date |
278.1.5
by John Arbash Meinel
Starting to flesh out the dialog with actual windows. |
269 |
|
270 |
rev_dict = {} |
|
271 |
rev_dict['committer'] = re.sub('<.*@.*>', '', rev.committer).strip(' ') |
|
272 |
rev_dict['summary'] = rev.get_summary() |
|
273 |
rev_dict['date'] = format_date(rev.timestamp, |
|
274 |
rev.timezone or 0, |
|
275 |
'original', date_fmt="%Y-%m-%d", |
|
276 |
show_offset=False) |
|
277 |
rev_dict['revision_id'] = rev.revision_id |
|
278 |
return rev_dict |
|
279 |
||
280 |
||
281 |
# class CommitDialog(gtk.Dialog):
|
|
282 |
# """ New implementation of the Commit dialog. """
|
|
283 |
# def __init__(self, wt, wtpath, notbranch, selected=None, parent=None):
|
|
284 |
# """ Initialize the Commit Dialog. """
|
|
285 |
# gtk.Dialog.__init__(self, title="Commit - Olive",
|
|
286 |
# parent=parent,
|
|
287 |
# flags=0,
|
|
288 |
# buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
|
|
289 |
#
|
|
290 |
# # Get arguments
|
|
291 |
# self.wt = wt
|
|
292 |
# self.wtpath = wtpath
|
|
293 |
# self.notbranch = notbranch
|
|
294 |
# self.selected = selected
|
|
295 |
#
|
|
296 |
# # Set the delta
|
|
297 |
# self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
|
|
298 |
# self.delta = self.wt.changes_from(self.old_tree)
|
|
299 |
#
|
|
300 |
# # Get pending merges
|
|
301 |
# self.pending = self._pending_merges(self.wt)
|
|
302 |
#
|
|
303 |
# # Do some preliminary checks
|
|
304 |
# self._is_checkout = False
|
|
305 |
# self._is_pending = False
|
|
306 |
# if self.wt is None and not self.notbranch:
|
|
307 |
# error_dialog(_('Directory does not have a working tree'),
|
|
308 |
# _('Operation aborted.'))
|
|
309 |
# self.close()
|
|
310 |
# return
|
|
311 |
#
|
|
312 |
# if self.notbranch:
|
|
313 |
# error_dialog(_('Directory is not a branch'),
|
|
314 |
# _('You can perform this action only in a branch.'))
|
|
315 |
# self.close()
|
|
316 |
# return
|
|
317 |
# else:
|
|
318 |
# if self.wt.branch.get_bound_location() is not None:
|
|
319 |
# # we have a checkout, so the local commit checkbox must appear
|
|
320 |
# self._is_checkout = True
|
|
321 |
#
|
|
322 |
# if self.pending:
|
|
323 |
# # There are pending merges, file selection not supported
|
|
324 |
# self._is_pending = True
|
|
325 |
#
|
|
326 |
# # Create the widgets
|
|
327 |
# # This is the main horizontal box, which is used to separate the commit
|
|
328 |
# # info from the diff window.
|
|
329 |
# self._hpane = gtk.HPaned()
|
|
330 |
# self._button_commit = gtk.Button(_("Comm_it"), use_underline=True)
|
|
331 |
# self._expander_files = gtk.Expander(_("File(s) to commit"))
|
|
332 |
# self._vpaned_main = gtk.VPaned()
|
|
333 |
# self._scrolledwindow_files = gtk.ScrolledWindow()
|
|
334 |
# self._scrolledwindow_message = gtk.ScrolledWindow()
|
|
335 |
# self._treeview_files = gtk.TreeView()
|
|
336 |
# self._vbox_message = gtk.VBox()
|
|
337 |
# self._label_message = gtk.Label(_("Commit message:"))
|
|
338 |
# self._textview_message = gtk.TextView()
|
|
339 |
#
|
|
340 |
# if self._is_pending:
|
|
341 |
# self._expander_merges = gtk.Expander(_("Pending merges"))
|
|
342 |
# self._vpaned_list = gtk.VPaned()
|
|
343 |
# self._scrolledwindow_merges = gtk.ScrolledWindow()
|
|
344 |
# self._treeview_merges = gtk.TreeView()
|
|
345 |
#
|
|
346 |
# # Set callbacks
|
|
347 |
# self._button_commit.connect('clicked', self._on_commit_clicked)
|
|
348 |
# self._treeview_files.connect('cursor-changed', self._on_treeview_files_cursor_changed)
|
|
349 |
# self._treeview_files.connect('row-activated', self._on_treeview_files_row_activated)
|
|
350 |
#
|
|
351 |
# # Set properties
|
|
352 |
# self._scrolledwindow_files.set_policy(gtk.POLICY_AUTOMATIC,
|
|
353 |
# gtk.POLICY_AUTOMATIC)
|
|
354 |
# self._scrolledwindow_message.set_policy(gtk.POLICY_AUTOMATIC,
|
|
355 |
# gtk.POLICY_AUTOMATIC)
|
|
356 |
# self._textview_message.modify_font(pango.FontDescription("Monospace"))
|
|
357 |
# self.set_default_size(500, 500)
|
|
358 |
# self._vpaned_main.set_position(200)
|
|
359 |
# self._button_commit.set_flags(gtk.CAN_DEFAULT)
|
|
360 |
#
|
|
361 |
# if self._is_pending:
|
|
362 |
# self._scrolledwindow_merges.set_policy(gtk.POLICY_AUTOMATIC,
|
|
363 |
# gtk.POLICY_AUTOMATIC)
|
|
364 |
# self._treeview_files.set_sensitive(False)
|
|
365 |
#
|
|
366 |
# # Construct the dialog
|
|
367 |
# self.action_area.pack_end(self._button_commit)
|
|
368 |
#
|
|
369 |
# self._scrolledwindow_files.add(self._treeview_files)
|
|
370 |
# self._scrolledwindow_message.add(self._textview_message)
|
|
371 |
#
|
|
372 |
# self._expander_files.add(self._scrolledwindow_files)
|
|
373 |
#
|
|
374 |
# self._vbox_message.pack_start(self._label_message, False, False)
|
|
375 |
# self._vbox_message.pack_start(self._scrolledwindow_message, True, True)
|
|
376 |
#
|
|
377 |
# if self._is_pending:
|
|
378 |
# self._expander_merges.add(self._scrolledwindow_merges)
|
|
379 |
# self._scrolledwindow_merges.add(self._treeview_merges)
|
|
380 |
# self._vpaned_list.add1(self._expander_files)
|
|
381 |
# self._vpaned_list.add2(self._expander_merges)
|
|
382 |
# self._vpaned_main.add1(self._vpaned_list)
|
|
383 |
# else:
|
|
384 |
# self._vpaned_main.add1(self._expander_files)
|
|
385 |
#
|
|
386 |
# self._vpaned_main.add2(self._vbox_message)
|
|
387 |
#
|
|
388 |
# self._hpane.pack1(self._vpaned_main)
|
|
389 |
# self.vbox.pack_start(self._hpane, expand=True, fill=True)
|
|
390 |
# if self._is_checkout:
|
|
391 |
# self._check_local = gtk.CheckButton(_("_Only commit locally"),
|
|
392 |
# use_underline=True)
|
|
393 |
# self.vbox.pack_start(self._check_local, False, False)
|
|
394 |
# if have_dbus:
|
|
395 |
# bus = dbus.SystemBus()
|
|
396 |
# proxy_obj = bus.get_object('org.freedesktop.NetworkManager',
|
|
397 |
# '/org/freedesktop/NetworkManager')
|
|
398 |
# dbus_iface = dbus.Interface(
|
|
399 |
# proxy_obj, 'org.freedesktop.NetworkManager')
|
|
400 |
# try:
|
|
401 |
# # 3 is the enum value for STATE_CONNECTED
|
|
402 |
# self._check_local.set_active(dbus_iface.state() != 3)
|
|
403 |
# except dbus.DBusException, e:
|
|
404 |
# # Silently drop errors. While DBus may be
|
|
405 |
# # available, NetworkManager doesn't necessarily have to be
|
|
406 |
# mutter("unable to get networkmanager state: %r" % e)
|
|
407 |
#
|
|
408 |
# # Create the file list
|
|
409 |
# self._create_file_view()
|
|
410 |
# # Create the pending merges
|
|
411 |
# self._create_pending_merges()
|
|
412 |
# self._create_diff_view()
|
|
413 |
#
|
|
414 |
# # Expand the corresponding expander
|
|
415 |
# if self._is_pending:
|
|
416 |
# self._expander_merges.set_expanded(True)
|
|
417 |
# else:
|
|
418 |
# self._expander_files.set_expanded(True)
|
|
419 |
#
|
|
420 |
# # Display dialog
|
|
421 |
# self.vbox.show_all()
|
|
422 |
#
|
|
423 |
# # Default to Commit button
|
|
424 |
# self._button_commit.grab_default()
|
|
425 |
#
|
|
426 |
# def _show_diff_view(self, treeview):
|
|
427 |
# # FIXME: the diff window freezes for some reason
|
|
428 |
# treeselection = treeview.get_selection()
|
|
429 |
# (model, iter) = treeselection.get_selected()
|
|
430 |
#
|
|
431 |
# if iter is not None:
|
|
432 |
# selected = model.get_value(iter, 3) # Get the real_path attribute
|
|
433 |
# self._diff_display.show_diff([selected])
|
|
434 |
#
|
|
435 |
# def _on_treeview_files_cursor_changed(self, treeview):
|
|
436 |
# self._show_diff_view(treeview)
|
|
437 |
#
|
|
438 |
# def _on_treeview_files_row_activated(self, treeview, path, view_column):
|
|
439 |
# self._show_diff_view(treeview)
|
|
440 |
#
|
|
441 |
# @show_bzr_error
|
|
442 |
# def _on_commit_clicked(self, button):
|
|
443 |
# """ Commit button clicked handler. """
|
|
444 |
# textbuffer = self._textview_message.get_buffer()
|
|
445 |
# start, end = textbuffer.get_bounds()
|
|
446 |
# message = textbuffer.get_text(start, end).decode('utf-8')
|
|
447 |
#
|
|
448 |
# if not self.pending:
|
|
449 |
# specific_files = self._get_specific_files()
|
|
450 |
# else:
|
|
451 |
# specific_files = None
|
|
452 |
#
|
|
453 |
# if message == '':
|
|
454 |
# response = question_dialog(_('Commit with an empty message?'),
|
|
455 |
# _('You can describe your commit intent in the message.'))
|
|
456 |
# if response == gtk.RESPONSE_NO:
|
|
457 |
# # Kindly give focus to message area
|
|
458 |
# self._textview_message.grab_focus()
|
|
459 |
# return
|
|
460 |
#
|
|
461 |
# if self._is_checkout:
|
|
462 |
# local = self._check_local.get_active()
|
|
463 |
# else:
|
|
464 |
# local = False
|
|
465 |
#
|
|
466 |
# if list(self.wt.unknowns()) != []:
|
|
467 |
# response = question_dialog(_("Commit with unknowns?"),
|
|
468 |
# _("Unknown files exist in the working tree. Commit anyway?"))
|
|
469 |
# if response == gtk.RESPONSE_NO:
|
|
470 |
# return
|
|
471 |
#
|
|
472 |
# try:
|
|
473 |
# self.wt.commit(message,
|
|
474 |
# allow_pointless=False,
|
|
475 |
# strict=False,
|
|
476 |
# local=local,
|
|
477 |
# specific_files=specific_files)
|
|
478 |
# except errors.PointlessCommit:
|
|
479 |
# response = question_dialog(_('Commit with no changes?'),
|
|
480 |
# _('There are no changes in the working tree.'))
|
|
481 |
# if response == gtk.RESPONSE_YES:
|
|
482 |
# self.wt.commit(message,
|
|
483 |
# allow_pointless=True,
|
|
484 |
# strict=False,
|
|
485 |
# local=local,
|
|
486 |
# specific_files=specific_files)
|
|
487 |
# self.response(gtk.RESPONSE_OK)
|
|
488 |
#
|
|
489 |
# def _pending_merges(self, wt):
|
|
490 |
# """ Return a list of pending merges or None if there are none of them. """
|
|
491 |
# parents = wt.get_parent_ids()
|
|
492 |
# if len(parents) < 2:
|
|
493 |
# return None
|
|
494 |
#
|
|
495 |
# import re
|
|
496 |
# from bzrlib.osutils import format_date
|
|
497 |
#
|
|
498 |
# pending = parents[1:]
|
|
499 |
# branch = wt.branch
|
|
500 |
# last_revision = parents[0]
|
|
501 |
#
|
|
502 |
# if last_revision is not None:
|
|
503 |
# try:
|
|
504 |
# ignore = set(branch.repository.get_ancestry(last_revision))
|
|
505 |
# except errors.NoSuchRevision:
|
|
506 |
# # the last revision is a ghost : assume everything is new
|
|
507 |
# # except for it
|
|
508 |
# ignore = set([None, last_revision])
|
|
509 |
# else:
|
|
510 |
# ignore = set([None])
|
|
511 |
#
|
|
512 |
# pm = []
|
|
513 |
# for merge in pending:
|
|
514 |
# ignore.add(merge)
|
|
515 |
# try:
|
|
516 |
# m_revision = branch.repository.get_revision(merge)
|
|
517 |
#
|
|
518 |
# rev = {}
|
|
519 |
# rev['committer'] = re.sub('<.*@.*>', '', m_revision.committer).strip(' ')
|
|
520 |
# rev['summary'] = m_revision.get_summary()
|
|
521 |
# rev['date'] = format_date(m_revision.timestamp,
|
|
522 |
# m_revision.timezone or 0,
|
|
523 |
# 'original', date_fmt="%Y-%m-%d",
|
|
524 |
# show_offset=False)
|
|
525 |
#
|
|
526 |
# pm.append(rev)
|
|
527 |
#
|
|
528 |
# inner_merges = branch.repository.get_ancestry(merge)
|
|
529 |
# assert inner_merges[0] is None
|
|
530 |
# inner_merges.pop(0)
|
|
531 |
# inner_merges.reverse()
|
|
532 |
# for mmerge in inner_merges:
|
|
533 |
# if mmerge in ignore:
|
|
534 |
# continue
|
|
535 |
# mm_revision = branch.repository.get_revision(mmerge)
|
|
536 |
#
|
|
537 |
# rev = {}
|
|
538 |
# rev['committer'] = re.sub('<.*@.*>', '', mm_revision.committer).strip(' ')
|
|
539 |
# rev['summary'] = mm_revision.get_summary()
|
|
540 |
# rev['date'] = format_date(mm_revision.timestamp,
|
|
541 |
# mm_revision.timezone or 0,
|
|
542 |
# 'original', date_fmt="%Y-%m-%d",
|
|
543 |
# show_offset=False)
|
|
544 |
#
|
|
545 |
# pm.append(rev)
|
|
546 |
#
|
|
547 |
# ignore.add(mmerge)
|
|
548 |
# except errors.NoSuchRevision:
|
|
549 |
# print "DEBUG: NoSuchRevision:", merge
|
|
550 |
#
|
|
551 |
# return pm
|
|
552 |
#
|
|
553 |
# def _create_file_view(self):
|
|
554 |
# self._file_store = gtk.ListStore(gobject.TYPE_BOOLEAN, # [0] checkbox
|
|
555 |
# gobject.TYPE_STRING, # [1] path to display
|
|
556 |
# gobject.TYPE_STRING, # [2] changes type
|
|
557 |
# gobject.TYPE_STRING) # [3] real path
|
|
558 |
# self._treeview_files.set_model(self._file_store)
|
|
559 |
# crt = gtk.CellRendererToggle()
|
|
560 |
# crt.set_property("activatable", True)
|
|
561 |
# crt.connect("toggled", self._toggle_commit, self._file_store)
|
|
562 |
# self._treeview_files.append_column(gtk.TreeViewColumn(_('Commit'),
|
|
563 |
# crt, active=0))
|
|
564 |
# self._treeview_files.append_column(gtk.TreeViewColumn(_('Path'),
|
|
565 |
# gtk.CellRendererText(), text=1))
|
|
566 |
# self._treeview_files.append_column(gtk.TreeViewColumn(_('Type'),
|
|
567 |
# gtk.CellRendererText(), text=2))
|
|
568 |
#
|
|
569 |
# for path, id, kind in self.delta.added:
|
|
570 |
# marker = osutils.kind_marker(kind)
|
|
571 |
# if self.selected is not None:
|
|
572 |
# if path == os.path.join(self.wtpath, self.selected):
|
|
573 |
# self._file_store.append([ True, path+marker, _('added'), path ])
|
|
574 |
# else:
|
|
575 |
# self._file_store.append([ False, path+marker, _('added'), path ])
|
|
576 |
# else:
|
|
577 |
# self._file_store.append([ True, path+marker, _('added'), path ])
|
|
578 |
#
|
|
579 |
# for path, id, kind in self.delta.removed:
|
|
580 |
# marker = osutils.kind_marker(kind)
|
|
581 |
# if self.selected is not None:
|
|
582 |
# if path == os.path.join(self.wtpath, self.selected):
|
|
583 |
# self._file_store.append([ True, path+marker, _('removed'), path ])
|
|
584 |
# else:
|
|
585 |
# self._file_store.append([ False, path+marker, _('removed'), path ])
|
|
586 |
# else:
|
|
587 |
# self._file_store.append([ True, path+marker, _('removed'), path ])
|
|
588 |
#
|
|
589 |
# for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed:
|
|
590 |
# marker = osutils.kind_marker(kind)
|
|
591 |
# if text_modified or meta_modified:
|
|
592 |
# changes = _('renamed and modified')
|
|
593 |
# else:
|
|
594 |
# changes = _('renamed')
|
|
595 |
# if self.selected is not None:
|
|
596 |
# if newpath == os.path.join(self.wtpath, self.selected):
|
|
597 |
# self._file_store.append([ True,
|
|
598 |
# oldpath+marker + ' => ' + newpath+marker,
|
|
599 |
# changes,
|
|
600 |
# newpath
|
|
601 |
# ])
|
|
602 |
# else:
|
|
603 |
# self._file_store.append([ False,
|
|
604 |
# oldpath+marker + ' => ' + newpath+marker,
|
|
605 |
# changes,
|
|
606 |
# newpath
|
|
607 |
# ])
|
|
608 |
# else:
|
|
609 |
# self._file_store.append([ True,
|
|
610 |
# oldpath+marker + ' => ' + newpath+marker,
|
|
611 |
# changes,
|
|
612 |
# newpath
|
|
613 |
# ])
|
|
614 |
#
|
|
615 |
# for path, id, kind, text_modified, meta_modified in self.delta.modified:
|
|
616 |
# marker = osutils.kind_marker(kind)
|
|
617 |
# if self.selected is not None:
|
|
618 |
# if path == os.path.join(self.wtpath, self.selected):
|
|
619 |
# self._file_store.append([ True, path+marker, _('modified'), path ])
|
|
620 |
# else:
|
|
621 |
# self._file_store.append([ False, path+marker, _('modified'), path ])
|
|
622 |
# else:
|
|
623 |
# self._file_store.append([ True, path+marker, _('modified'), path ])
|
|
624 |
#
|
|
625 |
# def _create_pending_merges(self):
|
|
626 |
# if not self.pending:
|
|
627 |
# return
|
|
628 |
#
|
|
629 |
# liststore = gtk.ListStore(gobject.TYPE_STRING,
|
|
630 |
# gobject.TYPE_STRING,
|
|
631 |
# gobject.TYPE_STRING)
|
|
632 |
# self._treeview_merges.set_model(liststore)
|
|
633 |
#
|
|
634 |
# self._treeview_merges.append_column(gtk.TreeViewColumn(_('Date'),
|
|
635 |
# gtk.CellRendererText(), text=0))
|
|
636 |
# self._treeview_merges.append_column(gtk.TreeViewColumn(_('Committer'),
|
|
637 |
# gtk.CellRendererText(), text=1))
|
|
638 |
# self._treeview_merges.append_column(gtk.TreeViewColumn(_('Summary'),
|
|
639 |
# gtk.CellRendererText(), text=2))
|
|
640 |
#
|
|
641 |
# for item in self.pending:
|
|
642 |
# liststore.append([ item['date'],
|
|
643 |
# item['committer'],
|
|
644 |
# item['summary'] ])
|
|
645 |
#
|
|
646 |
#
|
|
647 |
# def _create_diff_view(self):
|
|
648 |
# from diff import DiffDisplay
|
|
649 |
#
|
|
650 |
# self._diff_display = DiffDisplay()
|
|
651 |
# self._diff_display.set_trees(self.wt, self.wt.basis_tree())
|
|
652 |
# self._diff_display.show_diff(None)
|
|
653 |
# self._diff_display.show()
|
|
654 |
# self._hpane.pack2(self._diff_display)
|
|
655 |
#
|
|
656 |
# def _get_specific_files(self):
|
|
657 |
# ret = []
|
|
658 |
# it = self._file_store.get_iter_first()
|
|
659 |
# while it:
|
|
660 |
# if self._file_store.get_value(it, 0):
|
|
661 |
# # get real path from hidden column 3
|
|
662 |
# ret.append(self._file_store.get_value(it, 3))
|
|
663 |
# it = self._file_store.iter_next(it)
|
|
664 |
#
|
|
665 |
# return ret
|
|
666 |
#
|
|
667 |
# def _toggle_commit(self, cell, path, model):
|
|
668 |
# model[path][0] = not model[path][0]
|
|
669 |
# return
|