/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to commit.py

  • Committer: John Arbash Meinel
  • Date: 2007-10-01 21:10:06 UTC
  • mto: (322.1.1 trunk) (330.3.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 368.
  • Revision ID: john@arbash-meinel.com-20071001211006-gliyvcbbg989wh8n
Implement the file changes list on top of _iter_changes rather than
on top of changes_from.

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
    """Implementation of Commit."""
100
100
 
101
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
 
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
108
 
109
 
         self.setup_params()
110
 
         self.construct()
111
 
         # These could potentially be set based on the size of your monitor.
112
 
         # But for now, they seem like a reasonable default
113
 
         self.set_default_size(800, 600)
114
 
         self._hpane.set_position(300)
115
 
         self.fill_in_data()
 
109
        self.setup_params()
 
110
        self.construct()
 
111
        self.fill_in_data()
116
112
 
117
113
    def setup_params(self):
118
114
        """Setup the member variables for state."""
154
150
    def _fill_in_files(self):
155
151
        # We should really use _iter_changes, and then add a progress bar of
156
152
        # some kind.
157
 
        self._compute_delta()
158
 
 
159
153
        # While we fill in the view, hide the store
160
154
        store = self._files_store
161
155
        self._treeview_files.set_model(None)
165
159
        renamed = _('renamed')
166
160
        renamed_and_modified = _('renamed and modified')
167
161
        modified = _('modified')
 
162
        kind_changed = _('kind changed')
168
163
 
 
164
        # The store holds:
169
165
        # [file_id, real path, checkbox, display path, changes type]
170
 
        for path, file_id, kind in self._delta.added:
171
 
            marker = osutils.kind_marker(kind)
172
 
            store.append([file_id, path, True, path+marker, added])
173
 
 
174
 
        for path, file_id, kind in self._delta.removed:
175
 
            marker = osutils.kind_marker(kind)
176
 
            store.append([file_id, path, True, path+marker, removed])
177
 
 
178
 
        for oldpath, newpath, file_id, kind, text_mod, meta_mod in self._delta.renamed:
179
 
            marker = osutils.kind_marker(kind)
180
 
            if text_mod or meta_mod:
181
 
                changes = renamed_and_modified
182
 
            else:
183
 
                changes = renamed
184
 
            store.append([file_id, newpath, True,
185
 
                          oldpath+marker + '  =>  ' + newpath+marker,
186
 
                          changes,
187
 
                         ])
188
 
 
189
 
        for path, file_id, kind, text_mod, meta_mod in self._delta.modified:
190
 
            marker = osutils.kind_marker(kind)
191
 
            store.append([file_id, path, True, path+marker, modified])
 
166
        # _iter_changes returns:
 
167
        # (file_id, (path_in_source, path_in_target),
 
168
        #  changed_content, versioned, parent, name, kind,
 
169
        #  executable)
 
170
 
 
171
        # should we pass specific_files?
 
172
        self._wt.lock_read()
 
173
        self._basis_tree.lock_read()
 
174
        try:
 
175
            for (file_id, paths, changed_content, versioned, parent_ids, names,
 
176
                 kinds, executables) in self._wt._iter_changes(self._basis_tree):
 
177
 
 
178
                # Skip the root entry.
 
179
                if parent_ids == (None, None):
 
180
                    continue
 
181
 
 
182
                change_type = None
 
183
                if kinds[0] is None:
 
184
                    source_marker = ''
 
185
                else:
 
186
                    source_marker = osutils.kind_marker(kinds[0])
 
187
                if kinds[1] is None:
 
188
                    assert kinds[0] is not None
 
189
                    marker = osutils.kind_marker(kinds[0])
 
190
                else:
 
191
                    marker = osutils.kind_marker(kinds[1])
 
192
 
 
193
                real_path = paths[1]
 
194
                if real_path is None:
 
195
                    real_path = paths[0]
 
196
                assert real_path is not None
 
197
                display_path = real_path + marker
 
198
 
 
199
                present_source = versioned[0] and kinds[0] is not None
 
200
                present_target = versioned[1] and kinds[1] is not None
 
201
 
 
202
                if present_source != present_target:
 
203
                    if present_target:
 
204
                        change_type = added
 
205
                    else:
 
206
                        change_type = removed
 
207
                elif names[0] != names[1] or parent_ids[0] != parent_ids[1]:
 
208
                    # Renamed
 
209
                    if changed_content or executables[0] != executables[1]:
 
210
                        # and modified
 
211
                        change_type = renamed_and_modified
 
212
                    else:
 
213
                        change_type = renamed
 
214
                    display_path = (paths[0] + source_marker
 
215
                                    + ' => ' + paths[1] + marker)
 
216
                elif kinds[0] != kinds[1]:
 
217
                    change_type = kind_changed
 
218
                    display_path = (paths[0] + source_marker
 
219
                                    + ' => ' + paths[1] + marker)
 
220
                elif changed_content is True or executables[0] != executables[1]:
 
221
                    change_type = modified
 
222
                else:
 
223
                    assert False, "How did we get here?"
 
224
 
 
225
                store.append([file_id, real_path, True, display_path, change_type])
 
226
        finally:
 
227
            self._basis_tree.unlock()
 
228
            self._wt.unlock()
192
229
 
193
230
        self._treeview_files.set_model(store)
194
231
 
208
245
        self._hpane.show()
209
246
        self.set_focus(self._global_message_text_view)
210
247
 
 
248
        # These could potentially be set based on the size of your monitor.
 
249
        # But for now, they seem like a reasonable default
 
250
        self.set_default_size(800, 600)
 
251
        self._hpane.set_position(300)
 
252
 
211
253
    def _construct_left_pane(self):
212
254
        self._left_pane_box = gtk.VBox(homogeneous=False, spacing=5)
213
255
        self._construct_file_list()