/b-gtk/fix-viz

To get this branch, use:
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
278.1.23 by John Arbash Meinel
Beginning to support actual commit.
101
    _question_dialog = question_dialog
102
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
103
    def __init__(self, wt, selected=None, parent=None):
278.1.16 by John Arbash Meinel
Implement the file changes list on top of _iter_changes rather than
104
        gtk.Dialog.__init__(self, title="Commit - Olive",
105
                                  parent=parent,
106
                                  flags=0,
107
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
108
        self._wt = wt
109
        self._selected = selected
278.1.23 by John Arbash Meinel
Beginning to support actual commit.
110
        self.committed_revision_id = None # Nothing has been committed yet
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
111
278.1.16 by John Arbash Meinel
Implement the file changes list on top of _iter_changes rather than
112
        self.setup_params()
113
        self.construct()
114
        self.fill_in_data()
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
115
116
    def setup_params(self):
117
        """Setup the member variables for state."""
118
        self._basis_tree = self._wt.basis_tree()
278.1.12 by John Arbash Meinel
Delay computing the delta, and clean up some of the diff view names.
119
        self._delta = None
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
120
        self._pending = pending_revisions(self._wt)
121
122
        self._is_checkout = (self._wt.branch.get_bound_location() is not None)
123
278.1.14 by John Arbash Meinel
Tests that we fill out the pending list correctly.
124
    def fill_in_data(self):
125
        # Now that we are built, handle changes to the view based on the state
126
        self._fill_in_pending()
278.1.20 by John Arbash Meinel
We always select the All Files record in the files view,
127
        self._fill_in_diff()
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
128
        self._fill_in_files()
278.1.14 by John Arbash Meinel
Tests that we fill out the pending list correctly.
129
130
    def _fill_in_pending(self):
131
        if not self._pending:
132
            self._pending_box.hide()
133
            return
134
135
        # TODO: We'd really prefer this to be a nested list
136
        for rev, children in self._pending:
137
            rev_info = self._rev_to_pending_info(rev)
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
138
            self._pending_store.append([
278.1.14 by John Arbash Meinel
Tests that we fill out the pending list correctly.
139
                rev_info['revision_id'],
140
                rev_info['date'],
141
                rev_info['committer'],
142
                rev_info['summary'],
143
                ])
144
            for child in children:
145
                rev_info = self._rev_to_pending_info(child)
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
146
                self._pending_store.append([
278.1.14 by John Arbash Meinel
Tests that we fill out the pending list correctly.
147
                    rev_info['revision_id'],
148
                    rev_info['date'],
149
                    rev_info['committer'],
150
                    rev_info['summary'],
151
                    ])
152
        self._pending_box.show()
153
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
154
    def _fill_in_files(self):
155
        # We should really use _iter_changes, and then add a progress bar of
156
        # some kind.
157
        # While we fill in the view, hide the store
158
        store = self._files_store
159
        self._treeview_files.set_model(None)
160
161
        added = _('added')
162
        removed = _('removed')
163
        renamed = _('renamed')
164
        renamed_and_modified = _('renamed and modified')
165
        modified = _('modified')
278.1.16 by John Arbash Meinel
Implement the file changes list on top of _iter_changes rather than
166
        kind_changed = _('kind changed')
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
167
278.1.16 by John Arbash Meinel
Implement the file changes list on top of _iter_changes rather than
168
        # The store holds:
278.1.21 by John Arbash Meinel
Start tracking the per-file commit messages.
169
        # [file_id, real path, checkbox, display path, changes type, message]
278.1.16 by John Arbash Meinel
Implement the file changes list on top of _iter_changes rather than
170
        # _iter_changes returns:
171
        # (file_id, (path_in_source, path_in_target),
172
        #  changed_content, versioned, parent, name, kind,
173
        #  executable)
174
278.1.20 by John Arbash Meinel
We always select the All Files record in the files view,
175
        # The first entry is always the 'whole tree'
278.1.21 by John Arbash Meinel
Start tracking the per-file commit messages.
176
        store.append([None, None, True, 'All Files', '', ''])
278.1.16 by John Arbash Meinel
Implement the file changes list on top of _iter_changes rather than
177
        # should we pass specific_files?
178
        self._wt.lock_read()
179
        self._basis_tree.lock_read()
180
        try:
181
            for (file_id, paths, changed_content, versioned, parent_ids, names,
182
                 kinds, executables) in self._wt._iter_changes(self._basis_tree):
183
184
                # Skip the root entry.
185
                if parent_ids == (None, None):
186
                    continue
187
188
                change_type = None
189
                if kinds[0] is None:
190
                    source_marker = ''
191
                else:
192
                    source_marker = osutils.kind_marker(kinds[0])
193
                if kinds[1] is None:
194
                    assert kinds[0] is not None
195
                    marker = osutils.kind_marker(kinds[0])
196
                else:
197
                    marker = osutils.kind_marker(kinds[1])
198
199
                real_path = paths[1]
200
                if real_path is None:
201
                    real_path = paths[0]
202
                assert real_path is not None
203
                display_path = real_path + marker
204
205
                present_source = versioned[0] and kinds[0] is not None
206
                present_target = versioned[1] and kinds[1] is not None
207
208
                if present_source != present_target:
209
                    if present_target:
210
                        change_type = added
211
                    else:
212
                        change_type = removed
213
                elif names[0] != names[1] or parent_ids[0] != parent_ids[1]:
214
                    # Renamed
215
                    if changed_content or executables[0] != executables[1]:
216
                        # and modified
217
                        change_type = renamed_and_modified
218
                    else:
219
                        change_type = renamed
220
                    display_path = (paths[0] + source_marker
221
                                    + ' => ' + paths[1] + marker)
222
                elif kinds[0] != kinds[1]:
223
                    change_type = kind_changed
224
                    display_path = (paths[0] + source_marker
225
                                    + ' => ' + paths[1] + marker)
226
                elif changed_content is True or executables[0] != executables[1]:
227
                    change_type = modified
228
                else:
229
                    assert False, "How did we get here?"
230
278.1.21 by John Arbash Meinel
Start tracking the per-file commit messages.
231
                store.append([file_id, real_path, True, display_path,
232
                              change_type, ''])
278.1.16 by John Arbash Meinel
Implement the file changes list on top of _iter_changes rather than
233
        finally:
234
            self._basis_tree.unlock()
235
            self._wt.unlock()
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
236
237
        self._treeview_files.set_model(store)
278.1.21 by John Arbash Meinel
Start tracking the per-file commit messages.
238
        self._last_selected_file = None
278.1.20 by John Arbash Meinel
We always select the All Files record in the files view,
239
        self._treeview_files.set_cursor(0)
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
240
278.1.17 by John Arbash Meinel
Add a * reference for why you can't change the commit selection.
241
    def _fill_in_diff(self):
242
        self._diff_view.set_trees(self._wt, self._basis_tree)
243
278.1.12 by John Arbash Meinel
Delay computing the delta, and clean up some of the diff view names.
244
    def _compute_delta(self):
245
        self._delta = self._wt.changes_from(self._basis_tree)
246
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
247
    def construct(self):
248
        """Build up the dialog widgets."""
249
        # The primary pane which splits it into left and right (adjustable)
250
        # sections.
278.1.4 by John Arbash Meinel
Just playing around.
251
        self._hpane = gtk.HPaned()
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
252
253
        self._construct_left_pane()
254
        self._construct_right_pane()
278.1.23 by John Arbash Meinel
Beginning to support actual commit.
255
        self._construct_action_pane()
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
256
257
        self.vbox.pack_start(self._hpane)
258
        self._hpane.show()
259
        self.set_focus(self._global_message_text_view)
260
278.1.17 by John Arbash Meinel
Add a * reference for why you can't change the commit selection.
261
        # This seems like a reasonable default, we might like it to
262
        # be a bit wider, so that by default we can fit an 80-line diff in the
263
        # diff window.
264
        # Alternatively, we should be saving the last position/size rather than
265
        # setting it to a fixed value every time we start up.
266
        screen = self.get_screen()
267
        monitor = 0 # We would like it to be the monitor we are going to
268
                    # display on, but I don't know how to figure that out
269
                    # Only really useful for freaks like me that run dual
270
                    # monitor, with different sizes on the monitors
271
        monitor_rect = screen.get_monitor_geometry(monitor)
272
        width = int(monitor_rect.width * 0.66)
273
        height = int(monitor_rect.height * 0.66)
274
        self.set_default_size(width, height)
278.1.16 by John Arbash Meinel
Implement the file changes list on top of _iter_changes rather than
275
        self._hpane.set_position(300)
276
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
277
    def _construct_left_pane(self):
278.1.11 by John Arbash Meinel
Worked out the rest of the spacing.
278
        self._left_pane_box = gtk.VBox(homogeneous=False, spacing=5)
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
279
        self._construct_file_list()
280
        self._construct_pending_list()
281
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
282
        self._hpane.pack1(self._left_pane_box, resize=False, shrink=False)
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
283
        self._left_pane_box.show()
284
285
    def _construct_right_pane(self):
286
        # TODO: I really want to make it so the diff view gets more space than
287
        # the global commit message, and the per-file commit message gets even
288
        # less. When I did it with wxGlade, I set it to 4 for diff, 2 for
289
        # commit, and 1 for file commit, and it looked good. But I don't seem
290
        # to have a way to do that with the gtk boxes... :( (Which is extra
291
        # weird since wx uses gtk on Linux...)
278.1.10 by John Arbash Meinel
To get the space weighting I wanted, I turned to a Table.
292
        self._right_pane_table = gtk.Table(rows=10, columns=1, homogeneous=False)
278.1.11 by John Arbash Meinel
Worked out the rest of the spacing.
293
        self._right_pane_table.set_row_spacings(5)
294
        self._right_pane_table.set_col_spacings(5)
278.1.10 by John Arbash Meinel
To get the space weighting I wanted, I turned to a Table.
295
        self._right_pane_table_row = 0
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
296
        self._construct_diff_view()
297
        self._construct_file_message()
298
        self._construct_global_message()
299
278.1.10 by John Arbash Meinel
To get the space weighting I wanted, I turned to a Table.
300
        self._right_pane_table.show()
301
        self._hpane.pack2(self._right_pane_table, resize=True, shrink=True)
302
278.1.23 by John Arbash Meinel
Beginning to support actual commit.
303
    def _construct_action_pane(self):
304
        self._button_commit = gtk.Button(_("Comm_it"), use_underline=True)
305
        self._button_commit.connect('clicked', self._on_commit_clicked)
306
        self._button_commit.set_flags(gtk.CAN_DEFAULT)
307
        self.action_area.pack_end(self._button_commit)
308
278.1.10 by John Arbash Meinel
To get the space weighting I wanted, I turned to a Table.
309
    def _add_to_right_table(self, widget, weight, expanding=False):
310
        """Add another widget to the table
311
312
        :param widget: The object to add
313
        :param weight: How many rows does this widget get to request
314
        :param expanding: Should expand|fill|shrink be set?
315
        """
316
        end_row = self._right_pane_table_row + weight
317
        options = 0
318
        expand_opts = gtk.EXPAND | gtk.FILL | gtk.SHRINK
319
        if expanding:
320
            options = expand_opts
321
        self._right_pane_table.attach(widget, 0, 1,
322
                                      self._right_pane_table_row, end_row,
323
                                      xoptions=expand_opts, yoptions=options)
324
        self._right_pane_table_row = end_row
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
325
326
    def _construct_file_list(self):
278.1.11 by John Arbash Meinel
Worked out the rest of the spacing.
327
        self._files_box = gtk.VBox(homogeneous=False, spacing=0)
278.1.17 by John Arbash Meinel
Add a * reference for why you can't change the commit selection.
328
        file_label = gtk.Label(_('Files'))
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
329
        file_label.show()
330
        self._files_box.pack_start(file_label, expand=False)
331
332
        scroller = gtk.ScrolledWindow()
333
        scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
126.1.1 by Szilveszter Farkas (Phanatic)
New Commit dialog implementation (no more Glade).
334
        self._treeview_files = gtk.TreeView()
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
335
        self._treeview_files.show()
336
        scroller.add(self._treeview_files)
337
        scroller.show()
338
        scroller.set_shadow_type(gtk.SHADOW_IN)
339
        self._files_box.pack_start(scroller,
340
                                   expand=True, fill=True)
341
        self._files_box.show()
342
        self._left_pane_box.pack_start(self._files_box)
343
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
344
        liststore = gtk.ListStore(
345
            gobject.TYPE_STRING,  # [0] file_id
346
            gobject.TYPE_STRING,  # [1] real path
347
            gobject.TYPE_BOOLEAN, # [2] checkbox
348
            gobject.TYPE_STRING,  # [3] display path
349
            gobject.TYPE_STRING,  # [4] changes type
278.1.21 by John Arbash Meinel
Start tracking the per-file commit messages.
350
            gobject.TYPE_STRING,  # [5] commit message
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
351
            )
352
        self._files_store = liststore
353
        self._treeview_files.set_model(liststore)
354
        crt = gtk.CellRendererToggle()
278.1.20 by John Arbash Meinel
We always select the All Files record in the files view,
355
        crt.set_active(not bool(self._pending))
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
356
        crt.connect("toggled", self._toggle_commit, self._files_store)
278.1.17 by John Arbash Meinel
Add a * reference for why you can't change the commit selection.
357
        if self._pending:
358
            name = _('Commit*')
359
        else:
360
            name = _('Commit')
361
        self._treeview_files.append_column(gtk.TreeViewColumn(name,
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
362
                                           crt, active=2))
363
        self._treeview_files.append_column(gtk.TreeViewColumn(_('Path'),
364
                                           gtk.CellRendererText(), text=3))
365
        self._treeview_files.append_column(gtk.TreeViewColumn(_('Type'),
366
                                           gtk.CellRendererText(), text=4))
278.1.17 by John Arbash Meinel
Add a * reference for why you can't change the commit selection.
367
        self._treeview_files.connect('cursor-changed',
368
                                     self._on_treeview_files_cursor_changed)
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
369
370
    def _toggle_commit(self, cell, path, model):
278.1.20 by John Arbash Meinel
We always select the All Files record in the files view,
371
        if model[path][0] is None: # No file_id means 'All Files'
372
            new_val = not model[path][2]
373
            for node in model:
374
                node[2] = new_val
375
        else:
376
            model[path][2] = not model[path][2]
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
377
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
378
    def _construct_pending_list(self):
379
        # Pending information defaults to hidden, we put it all in 1 box, so
380
        # that we can show/hide all of them at once
381
        self._pending_box = gtk.VBox()
382
        self._pending_box.hide()
383
384
        pending_message = gtk.Label()
385
        pending_message.set_markup(
278.1.17 by John Arbash Meinel
Add a * reference for why you can't change the commit selection.
386
            _('<i>* Cannot select specific files when merging</i>'))
278.1.11 by John Arbash Meinel
Worked out the rest of the spacing.
387
        self._pending_box.pack_start(pending_message, expand=False, padding=5)
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
388
        pending_message.show()
389
278.1.17 by John Arbash Meinel
Add a * reference for why you can't change the commit selection.
390
        pending_label = gtk.Label(_('Pending Revisions'))
278.1.11 by John Arbash Meinel
Worked out the rest of the spacing.
391
        self._pending_box.pack_start(pending_label, expand=False, padding=0)
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
392
        pending_label.show()
393
394
        scroller = gtk.ScrolledWindow()
395
        scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
396
        self._treeview_pending = gtk.TreeView()
397
        scroller.add(self._treeview_pending)
398
        scroller.show()
399
        scroller.set_shadow_type(gtk.SHADOW_IN)
400
        self._pending_box.pack_start(scroller,
278.1.11 by John Arbash Meinel
Worked out the rest of the spacing.
401
                                     expand=True, fill=True, padding=5)
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
402
        self._treeview_pending.show()
403
        self._left_pane_box.pack_start(self._pending_box)
404
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
405
        liststore = gtk.ListStore(gobject.TYPE_STRING, # revision_id
406
                                  gobject.TYPE_STRING, # date
407
                                  gobject.TYPE_STRING, # committer
408
                                  gobject.TYPE_STRING, # summary
278.1.14 by John Arbash Meinel
Tests that we fill out the pending list correctly.
409
                                 )
278.1.15 by John Arbash Meinel
Hook up the list of modified files.
410
        self._pending_store = liststore
278.1.14 by John Arbash Meinel
Tests that we fill out the pending list correctly.
411
        self._treeview_pending.set_model(liststore)
412
        self._treeview_pending.append_column(gtk.TreeViewColumn(_('Date'),
413
                                             gtk.CellRendererText(), text=1))
414
        self._treeview_pending.append_column(gtk.TreeViewColumn(_('Committer'),
415
                                             gtk.CellRendererText(), text=2))
416
        self._treeview_pending.append_column(gtk.TreeViewColumn(_('Summary'),
417
                                             gtk.CellRendererText(), text=3))
418
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
419
    def _construct_diff_view(self):
278.1.12 by John Arbash Meinel
Delay computing the delta, and clean up some of the diff view names.
420
        from diff import DiffView
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
421
422
        self._diff_label = gtk.Label(_('Diff for whole tree'))
278.1.11 by John Arbash Meinel
Worked out the rest of the spacing.
423
        self._diff_label.set_alignment(0, 0)
424
        self._right_pane_table.set_row_spacing(self._right_pane_table_row, 0)
278.1.10 by John Arbash Meinel
To get the space weighting I wanted, I turned to a Table.
425
        self._add_to_right_table(self._diff_label, 1, False)
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
426
        self._diff_label.show()
427
278.1.12 by John Arbash Meinel
Delay computing the delta, and clean up some of the diff view names.
428
        self._diff_view = DiffView()
278.1.10 by John Arbash Meinel
To get the space weighting I wanted, I turned to a Table.
429
        self._add_to_right_table(self._diff_view, 4, True)
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
430
        self._diff_view.show()
431
432
    def _construct_file_message(self):
433
        file_message_box = gtk.VBox()
278.1.9 by John Arbash Meinel
Move all text entry boxes into a ScrolledWindow, so that they don't change size constantly.
434
        scroller = gtk.ScrolledWindow()
435
        scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
436
437
        self._file_message_text_view = gtk.TextView()
438
        scroller.add(self._file_message_text_view)
439
        scroller.show()
440
        scroller.set_shadow_type(gtk.SHADOW_IN)
441
        file_message_box.pack_start(scroller, expand=True, fill=True)
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
442
443
        self._file_message_text_view.modify_font(pango.FontDescription("Monospace"))
444
        self._file_message_text_view.set_wrap_mode(gtk.WRAP_WORD)
445
        self._file_message_text_view.set_accepts_tab(False)
446
        self._file_message_text_view.show()
447
278.1.21 by John Arbash Meinel
Start tracking the per-file commit messages.
448
        self._file_message_expander = gtk.Expander(_('File commit message'))
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
449
        self._file_message_expander.add(file_message_box)
450
        file_message_box.show()
278.1.10 by John Arbash Meinel
To get the space weighting I wanted, I turned to a Table.
451
        self._add_to_right_table(self._file_message_expander, 1, False)
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
452
        self._file_message_expander.show()
453
454
    def _construct_global_message(self):
455
        self._global_message_label = gtk.Label(_('Global Commit Message'))
278.1.11 by John Arbash Meinel
Worked out the rest of the spacing.
456
        self._global_message_label.set_alignment(0, 0)
457
        self._right_pane_table.set_row_spacing(self._right_pane_table_row, 0)
278.1.10 by John Arbash Meinel
To get the space weighting I wanted, I turned to a Table.
458
        self._add_to_right_table(self._global_message_label, 1, False)
278.1.11 by John Arbash Meinel
Worked out the rest of the spacing.
459
        # Can we remove the spacing between the label and the box?
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
460
        self._global_message_label.show()
461
278.1.9 by John Arbash Meinel
Move all text entry boxes into a ScrolledWindow, so that they don't change size constantly.
462
        scroller = gtk.ScrolledWindow()
463
        scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
464
465
        self._global_message_text_view = gtk.TextView()
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
466
        self._global_message_text_view.modify_font(pango.FontDescription("Monospace"))
278.1.9 by John Arbash Meinel
Move all text entry boxes into a ScrolledWindow, so that they don't change size constantly.
467
        scroller.add(self._global_message_text_view)
468
        scroller.show()
469
        scroller.set_shadow_type(gtk.SHADOW_IN)
278.1.10 by John Arbash Meinel
To get the space weighting I wanted, I turned to a Table.
470
        self._add_to_right_table(scroller, 2, True)
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
471
        self._file_message_text_view.set_wrap_mode(gtk.WRAP_WORD)
472
        self._file_message_text_view.set_accepts_tab(False)
473
        self._global_message_text_view.show()
474
278.1.17 by John Arbash Meinel
Add a * reference for why you can't change the commit selection.
475
    def _on_treeview_files_cursor_changed(self, treeview):
278.1.18 by John Arbash Meinel
Start checking the diff view is correct.
476
        treeselection = treeview.get_selection()
278.1.21 by John Arbash Meinel
Start tracking the per-file commit messages.
477
        (model, selection) = treeselection.get_selected()
278.1.17 by John Arbash Meinel
Add a * reference for why you can't change the commit selection.
478
278.1.21 by John Arbash Meinel
Start tracking the per-file commit messages.
479
        if selection is not None:
480
            path, display_path = model.get(selection, 1, 3)
278.1.18 by John Arbash Meinel
Start checking the diff view is correct.
481
            self._diff_label.set_text(_('Diff for ') + display_path)
278.1.20 by John Arbash Meinel
We always select the All Files record in the files view,
482
            if path is None:
483
                self._diff_view.show_diff(None)
484
            else:
485
                self._diff_view.show_diff([path])
278.1.21 by John Arbash Meinel
Start tracking the per-file commit messages.
486
            self._update_per_file_info(selection)
487
488
    def _save_current_file_message(self):
489
        if self._last_selected_file is None:
490
            return # Nothing to save
491
        text_buffer = self._file_message_text_view.get_buffer()
492
        cur_text = text_buffer.get_text(text_buffer.get_start_iter(),
493
                                        text_buffer.get_end_iter())
494
        last_selected = self._files_store.get_iter(self._last_selected_file)
495
        self._files_store.set_value(last_selected, 5, cur_text)
496
497
    def _update_per_file_info(self, selection):
498
        # The node is changing, so cache the current message
499
        self._save_current_file_message()
500
        text_buffer = self._file_message_text_view.get_buffer()
501
        file_id, display_path, message = self._files_store.get(selection, 0, 3, 5)
502
        if file_id is None: # Whole tree
503
            self._file_message_expander.set_label(_('File commit message'))
504
            self._file_message_expander.set_expanded(False)
505
            self._file_message_expander.set_sensitive(False)
506
            text_buffer.set_text('')
507
            self._last_selected_file = None
508
        else:
509
            self._file_message_expander.set_label(_('Commit message for ')
510
                                                  + display_path)
511
            self._file_message_expander.set_expanded(True)
512
            self._file_message_expander.set_sensitive(True)
513
            text_buffer.set_text(message)
514
            self._last_selected_file = self._files_store.get_path(selection)
278.1.17 by John Arbash Meinel
Add a * reference for why you can't change the commit selection.
515
278.1.23 by John Arbash Meinel
Beginning to support actual commit.
516
    @show_bzr_error
517
    def _on_commit_clicked(self, button):
518
        """ Commit button clicked handler. """
519
        self._do_commit()
520
521
    def _do_commit(self):
522
        buf = self._global_message_text_view.get_buffer()
523
        start, end = buf.get_bounds()
524
        message = buf.get_text(start, end).decode('utf-8')
525
526
        if message == '':
527
            response = self._question_dialog(
528
                            _('Commit with an empty message?'),
529
                            _('You can describe your commit intent in the message.'))
530
            if response == gtk.RESPONSE_NO:
531
                # Kindly give focus to message area
532
                self._global_message_text_view.grab_focus()
533
                return
534
535
        # if not self.pending:
536
        #     specific_files = self._get_specific_files()
537
        # else:
538
        #     specific_files = None
539
540
        # if self._is_checkout:
541
        #     local = self._check_local.get_active()
542
        # else:
543
        #     local = False
544
545
        # if list(self._wt.unknowns()) != []:
546
        #     response = question_dialog(_("Commit with unknowns?"),
547
        #        _("Unknown files exist in the working tree. Commit anyway?"))
548
        #     if response == gtk.RESPONSE_NO:
549
        #         return
550
551
        local = False
552
        specific_files = None
553
        try:
554
            rev_id = self._wt.commit(message,
555
                       allow_pointless=False,
556
                       strict=False,
557
                       local=local,
558
                       specific_files=specific_files)
559
        except errors.PointlessCommit:
560
            response = question_dialog(_('Commit with no changes?'),
561
                                       _('There are no changes in the working tree.'))
562
            if response == gtk.RESPONSE_YES:
563
                rev_id = self._wt.commit(message,
564
                               allow_pointless=True,
565
                               strict=False,
566
                               local=local,
567
                               specific_files=specific_files)
568
        self.committed_revision_id = rev_id
569
        self.response(gtk.RESPONSE_OK)
570
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
571
    @staticmethod
572
    def _rev_to_pending_info(rev):
573
        """Get the information from a pending merge."""
126.1.1 by Szilveszter Farkas (Phanatic)
New Commit dialog implementation (no more Glade).
574
        from bzrlib.osutils import format_date
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
575
576
        rev_dict = {}
577
        rev_dict['committer'] = re.sub('<.*@.*>', '', rev.committer).strip(' ')
578
        rev_dict['summary'] = rev.get_summary()
579
        rev_dict['date'] = format_date(rev.timestamp,
580
                                       rev.timezone or 0,
581
                                       'original', date_fmt="%Y-%m-%d",
582
                                       show_offset=False)
583
        rev_dict['revision_id'] = rev.revision_id
584
        return rev_dict
585
586
587
# class CommitDialog(gtk.Dialog):
588
#     """ New implementation of the Commit dialog. """
589
#     def __init__(self, wt, wtpath, notbranch, selected=None, parent=None):
590
#         """ Initialize the Commit Dialog. """
591
#         gtk.Dialog.__init__(self, title="Commit - Olive",
592
#                                   parent=parent,
593
#                                   flags=0,
594
#                                   buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
595
#         
596
#         # Get arguments
597
#         self.wt = wt
598
#         self.wtpath = wtpath
599
#         self.notbranch = notbranch
600
#         self.selected = selected
601
#         
602
#         # Set the delta
603
#         self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
604
#         self.delta = self.wt.changes_from(self.old_tree)
605
#         
606
#         # Get pending merges
607
#         self.pending = self._pending_merges(self.wt)
608
#         
609
#         # Do some preliminary checks
610
#         self._is_checkout = False
611
#         self._is_pending = False
612
#         if self.wt is None and not self.notbranch:
613
#             error_dialog(_('Directory does not have a working tree'),
614
#                          _('Operation aborted.'))
615
#             self.close()
616
#             return
617
# 
618
#         if self.notbranch:
619
#             error_dialog(_('Directory is not a branch'),
620
#                          _('You can perform this action only in a branch.'))
621
#             self.close()
622
#             return
623
#         else:
624
#             if self.wt.branch.get_bound_location() is not None:
625
#                 # we have a checkout, so the local commit checkbox must appear
626
#                 self._is_checkout = True
627
#             
628
#             if self.pending:
629
#                 # There are pending merges, file selection not supported
630
#                 self._is_pending = True
631
#         
632
#         # Create the widgets
633
#         # This is the main horizontal box, which is used to separate the commit
634
#         # info from the diff window.
635
#         self._hpane = gtk.HPaned()
636
#         self._button_commit = gtk.Button(_("Comm_it"), use_underline=True)
637
#         self._expander_files = gtk.Expander(_("File(s) to commit"))
638
#         self._vpaned_main = gtk.VPaned()
639
#         self._scrolledwindow_files = gtk.ScrolledWindow()
640
#         self._scrolledwindow_message = gtk.ScrolledWindow()
641
#         self._treeview_files = gtk.TreeView()
642
#         self._vbox_message = gtk.VBox()
643
#         self._label_message = gtk.Label(_("Commit message:"))
644
#         self._textview_message = gtk.TextView()
645
#         
646
#         if self._is_pending:
647
#             self._expander_merges = gtk.Expander(_("Pending merges"))
648
#             self._vpaned_list = gtk.VPaned()
649
#             self._scrolledwindow_merges = gtk.ScrolledWindow()
650
#             self._treeview_merges = gtk.TreeView()
651
# 
652
#         # Set callbacks
653
#         self._button_commit.connect('clicked', self._on_commit_clicked)
654
#         self._treeview_files.connect('cursor-changed', self._on_treeview_files_cursor_changed)
655
#         self._treeview_files.connect('row-activated', self._on_treeview_files_row_activated)
656
#         
657
#         # Set properties
658
#         self._scrolledwindow_files.set_policy(gtk.POLICY_AUTOMATIC,
659
#                                               gtk.POLICY_AUTOMATIC)
660
#         self._scrolledwindow_message.set_policy(gtk.POLICY_AUTOMATIC,
661
#                                                 gtk.POLICY_AUTOMATIC)
662
#         self._textview_message.modify_font(pango.FontDescription("Monospace"))
663
#         self.set_default_size(500, 500)
664
#         self._vpaned_main.set_position(200)
665
#         self._button_commit.set_flags(gtk.CAN_DEFAULT)
666
# 
667
#         if self._is_pending:
668
#             self._scrolledwindow_merges.set_policy(gtk.POLICY_AUTOMATIC,
669
#                                                    gtk.POLICY_AUTOMATIC)
670
#             self._treeview_files.set_sensitive(False)
671
#         
672
#         # Construct the dialog
673
#         self.action_area.pack_end(self._button_commit)
674
#         
675
#         self._scrolledwindow_files.add(self._treeview_files)
676
#         self._scrolledwindow_message.add(self._textview_message)
677
#         
678
#         self._expander_files.add(self._scrolledwindow_files)
679
#         
680
#         self._vbox_message.pack_start(self._label_message, False, False)
681
#         self._vbox_message.pack_start(self._scrolledwindow_message, True, True)
682
#         
683
#         if self._is_pending:        
684
#             self._expander_merges.add(self._scrolledwindow_merges)
685
#             self._scrolledwindow_merges.add(self._treeview_merges)
686
#             self._vpaned_list.add1(self._expander_files)
687
#             self._vpaned_list.add2(self._expander_merges)
688
#             self._vpaned_main.add1(self._vpaned_list)
689
#         else:
690
#             self._vpaned_main.add1(self._expander_files)
691
# 
692
#         self._vpaned_main.add2(self._vbox_message)
693
#         
694
#         self._hpane.pack1(self._vpaned_main)
695
#         self.vbox.pack_start(self._hpane, expand=True, fill=True)
696
#         if self._is_checkout: 
697
#             self._check_local = gtk.CheckButton(_("_Only commit locally"),
698
#                                                 use_underline=True)
699
#             self.vbox.pack_start(self._check_local, False, False)
700
#             if have_dbus:
701
#                 bus = dbus.SystemBus()
702
#                 proxy_obj = bus.get_object('org.freedesktop.NetworkManager', 
703
#                               '/org/freedesktop/NetworkManager')
704
#                 dbus_iface = dbus.Interface(
705
#                         proxy_obj, 'org.freedesktop.NetworkManager')
706
#                 try:
707
#                     # 3 is the enum value for STATE_CONNECTED
708
#                     self._check_local.set_active(dbus_iface.state() != 3)
709
#                 except dbus.DBusException, e:
710
#                     # Silently drop errors. While DBus may be 
711
#                     # available, NetworkManager doesn't necessarily have to be
712
#                     mutter("unable to get networkmanager state: %r" % e)
713
#                 
714
#         # Create the file list
715
#         self._create_file_view()
716
#         # Create the pending merges
717
#         self._create_pending_merges()
718
#         self._create_diff_view()
719
#         
720
#         # Expand the corresponding expander
721
#         if self._is_pending:
722
#             self._expander_merges.set_expanded(True)
723
#         else:
724
#             self._expander_files.set_expanded(True)
725
#         
726
#         # Display dialog
727
#         self.vbox.show_all()
728
#         
729
#         # Default to Commit button
730
#         self._button_commit.grab_default()
731
#     
732
#     def _show_diff_view(self, treeview):
733
#         # FIXME: the diff window freezes for some reason
734
#         treeselection = treeview.get_selection()
735
#         (model, iter) = treeselection.get_selected()
736
# 
737
#         if iter is not None:
738
#             selected = model.get_value(iter, 3) # Get the real_path attribute
739
#             self._diff_display.show_diff([selected])
740
# 
741
#     def _on_treeview_files_cursor_changed(self, treeview):
742
#         self._show_diff_view(treeview)
743
#         
744
#     def _on_treeview_files_row_activated(self, treeview, path, view_column):
745
#         self._show_diff_view(treeview)
746
#     
747
#     @show_bzr_error
748
#     def _on_commit_clicked(self, button):
749
#         """ Commit button clicked handler. """
750
#         textbuffer = self._textview_message.get_buffer()
751
#         start, end = textbuffer.get_bounds()
752
#         message = textbuffer.get_text(start, end).decode('utf-8')
753
#         
754
#         if not self.pending:
755
#             specific_files = self._get_specific_files()
756
#         else:
757
#             specific_files = None
758
# 
759
#         if message == '':
760
#             response = question_dialog(_('Commit with an empty message?'),
761
#                                        _('You can describe your commit intent in the message.'))
762
#             if response == gtk.RESPONSE_NO:
763
#                 # Kindly give focus to message area
764
#                 self._textview_message.grab_focus()
765
#                 return
766
# 
767
#         if self._is_checkout:
768
#             local = self._check_local.get_active()
769
#         else:
770
#             local = False
771
# 
772
#         if list(self.wt.unknowns()) != []:
773
#             response = question_dialog(_("Commit with unknowns?"),
774
#                _("Unknown files exist in the working tree. Commit anyway?"))
775
#             if response == gtk.RESPONSE_NO:
776
#                 return
777
#         
778
#         try:
779
#             self.wt.commit(message,
780
#                        allow_pointless=False,
781
#                        strict=False,
782
#                        local=local,
783
#                        specific_files=specific_files)
784
#         except errors.PointlessCommit:
785
#             response = question_dialog(_('Commit with no changes?'),
786
#                                        _('There are no changes in the working tree.'))
787
#             if response == gtk.RESPONSE_YES:
788
#                 self.wt.commit(message,
789
#                                allow_pointless=True,
790
#                                strict=False,
791
#                                local=local,
792
#                                specific_files=specific_files)
793
#         self.response(gtk.RESPONSE_OK)
794
# 
795
#     def _pending_merges(self, wt):
796
#         """ Return a list of pending merges or None if there are none of them. """
797
#         parents = wt.get_parent_ids()
798
#         if len(parents) < 2:
799
#             return None
800
#         
801
#         import re
802
#         from bzrlib.osutils import format_date
803
#         
804
#         pending = parents[1:]
805
#         branch = wt.branch
806
#         last_revision = parents[0]
807
#         
808
#         if last_revision is not None:
809
#             try:
810
#                 ignore = set(branch.repository.get_ancestry(last_revision))
811
#             except errors.NoSuchRevision:
812
#                 # the last revision is a ghost : assume everything is new 
813
#                 # except for it
814
#                 ignore = set([None, last_revision])
815
#         else:
816
#             ignore = set([None])
817
#         
818
#         pm = []
819
#         for merge in pending:
820
#             ignore.add(merge)
821
#             try:
822
#                 m_revision = branch.repository.get_revision(merge)
823
#                 
824
#                 rev = {}
825
#                 rev['committer'] = re.sub('<.*@.*>', '', m_revision.committer).strip(' ')
826
#                 rev['summary'] = m_revision.get_summary()
827
#                 rev['date'] = format_date(m_revision.timestamp,
828
#                                           m_revision.timezone or 0, 
829
#                                           'original', date_fmt="%Y-%m-%d",
830
#                                           show_offset=False)
831
#                 
832
#                 pm.append(rev)
833
#                 
834
#                 inner_merges = branch.repository.get_ancestry(merge)
835
#                 assert inner_merges[0] is None
836
#                 inner_merges.pop(0)
837
#                 inner_merges.reverse()
838
#                 for mmerge in inner_merges:
839
#                     if mmerge in ignore:
840
#                         continue
841
#                     mm_revision = branch.repository.get_revision(mmerge)
842
#                     
843
#                     rev = {}
844
#                     rev['committer'] = re.sub('<.*@.*>', '', mm_revision.committer).strip(' ')
845
#                     rev['summary'] = mm_revision.get_summary()
846
#                     rev['date'] = format_date(mm_revision.timestamp,
847
#                                               mm_revision.timezone or 0, 
848
#                                               'original', date_fmt="%Y-%m-%d",
849
#                                               show_offset=False)
850
#                 
851
#                     pm.append(rev)
852
#                     
853
#                     ignore.add(mmerge)
854
#             except errors.NoSuchRevision:
855
#                 print "DEBUG: NoSuchRevision:", merge
856
#         
857
#         return pm
858
# 
859
#     def _create_file_view(self):
860
#         self._file_store = gtk.ListStore(gobject.TYPE_BOOLEAN,   # [0] checkbox
861
#                                          gobject.TYPE_STRING,    # [1] path to display
862
#                                          gobject.TYPE_STRING,    # [2] changes type
863
#                                          gobject.TYPE_STRING)    # [3] real path
864
#         self._treeview_files.set_model(self._file_store)
865
#         crt = gtk.CellRendererToggle()
866
#         crt.set_property("activatable", True)
867
#         crt.connect("toggled", self._toggle_commit, self._file_store)
868
#         self._treeview_files.append_column(gtk.TreeViewColumn(_('Commit'),
869
#                                      crt, active=0))
870
#         self._treeview_files.append_column(gtk.TreeViewColumn(_('Path'),
871
#                                      gtk.CellRendererText(), text=1))
872
#         self._treeview_files.append_column(gtk.TreeViewColumn(_('Type'),
873
#                                      gtk.CellRendererText(), text=2))
874
# 
875
#         for path, id, kind in self.delta.added:
876
#             marker = osutils.kind_marker(kind)
877
#             if self.selected is not None:
878
#                 if path == os.path.join(self.wtpath, self.selected):
879
#                     self._file_store.append([ True, path+marker, _('added'), path ])
880
#                 else:
881
#                     self._file_store.append([ False, path+marker, _('added'), path ])
882
#             else:
883
#                 self._file_store.append([ True, path+marker, _('added'), path ])
884
# 
885
#         for path, id, kind in self.delta.removed:
886
#             marker = osutils.kind_marker(kind)
887
#             if self.selected is not None:
888
#                 if path == os.path.join(self.wtpath, self.selected):
889
#                     self._file_store.append([ True, path+marker, _('removed'), path ])
890
#                 else:
891
#                     self._file_store.append([ False, path+marker, _('removed'), path ])
892
#             else:
893
#                 self._file_store.append([ True, path+marker, _('removed'), path ])
894
# 
895
#         for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed:
896
#             marker = osutils.kind_marker(kind)
897
#             if text_modified or meta_modified:
898
#                 changes = _('renamed and modified')
899
#             else:
900
#                 changes = _('renamed')
901
#             if self.selected is not None:
902
#                 if newpath == os.path.join(self.wtpath, self.selected):
903
#                     self._file_store.append([ True,
904
#                                               oldpath+marker + '  =>  ' + newpath+marker,
905
#                                               changes,
906
#                                               newpath
907
#                                             ])
908
#                 else:
909
#                     self._file_store.append([ False,
910
#                                               oldpath+marker + '  =>  ' + newpath+marker,
911
#                                               changes,
912
#                                               newpath
913
#                                             ])
914
#             else:
915
#                 self._file_store.append([ True,
916
#                                           oldpath+marker + '  =>  ' + newpath+marker,
917
#                                           changes,
918
#                                           newpath
919
#                                         ])
920
# 
921
#         for path, id, kind, text_modified, meta_modified in self.delta.modified:
922
#             marker = osutils.kind_marker(kind)
923
#             if self.selected is not None:
924
#                 if path == os.path.join(self.wtpath, self.selected):
925
#                     self._file_store.append([ True, path+marker, _('modified'), path ])
926
#                 else:
927
#                     self._file_store.append([ False, path+marker, _('modified'), path ])
928
#             else:
929
#                 self._file_store.append([ True, path+marker, _('modified'), path ])
930
#     
931
#     def _create_pending_merges(self):
932
#         if not self.pending:
933
#             return
934
#         
935
#         liststore = gtk.ListStore(gobject.TYPE_STRING,
936
#                                   gobject.TYPE_STRING,
937
#                                   gobject.TYPE_STRING)
938
#         self._treeview_merges.set_model(liststore)
939
#         
940
#         self._treeview_merges.append_column(gtk.TreeViewColumn(_('Date'),
941
#                                             gtk.CellRendererText(), text=0))
942
#         self._treeview_merges.append_column(gtk.TreeViewColumn(_('Committer'),
943
#                                             gtk.CellRendererText(), text=1))
944
#         self._treeview_merges.append_column(gtk.TreeViewColumn(_('Summary'),
945
#                                             gtk.CellRendererText(), text=2))
946
#         
947
#         for item in self.pending:
948
#             liststore.append([ item['date'],
949
#                                item['committer'],
950
#                                item['summary'] ])
951
#     
952
# 
953
#     def _create_diff_view(self):
278.1.12 by John Arbash Meinel
Delay computing the delta, and clean up some of the diff view names.
954
#         from diff import DiffView
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
955
# 
278.1.12 by John Arbash Meinel
Delay computing the delta, and clean up some of the diff view names.
956
#         self._diff_display = DiffView()
278.1.5 by John Arbash Meinel
Starting to flesh out the dialog with actual windows.
957
#         self._diff_display.set_trees(self.wt, self.wt.basis_tree())
958
#         self._diff_display.show_diff(None)
959
#         self._diff_display.show()
960
#         self._hpane.pack2(self._diff_display)
961
# 
962
#     def _get_specific_files(self):
963
#         ret = []
964
#         it = self._file_store.get_iter_first()
965
#         while it:
966
#             if self._file_store.get_value(it, 0):
967
#                 # get real path from hidden column 3
968
#                 ret.append(self._file_store.get_value(it, 3))
969
#             it = self._file_store.iter_next(it)
970
# 
971
#         return ret
972
#     
973
#     def _toggle_commit(self, cell, path, model):
974
#         model[path][0] = not model[path][0]
975
#         return