/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 olive/commit.py

  • Committer: Jelmer Vernooij
  • Date: 2006-09-13 20:19:31 UTC
  • mfrom: (0.8.79 main)
  • mto: (0.8.83 merge)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060913201931-23adba246d4d6529
Merge main branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pygtk.require("2.0")
22
22
except:
23
23
    pass
24
 
import gtk
25
 
import gtk.glade
26
 
import gobject
27
 
import pango
 
24
try:
 
25
    import gtk
 
26
    import gtk.glade
 
27
    import gobject
 
28
    import pango
 
29
except:
 
30
    sys.exit(1)
28
31
 
29
32
from bzrlib import version_info
30
33
 
31
34
import bzrlib.errors as errors
32
35
from bzrlib.workingtree import WorkingTree
33
36
 
34
 
from dialog import error_dialog
35
 
from olive import gladefile
36
 
 
37
37
class OliveCommit:
38
38
    """ Display Commit dialog and perform the needed actions. """
39
 
    def __init__(self, wt, wtpath):
 
39
    def __init__(self, gladefile, comm, dialog):
40
40
        """ Initialize the Commit dialog. """
41
 
        self.glade = gtk.glade.XML(gladefile, 'window_commit', 'olive-gtk')
42
 
        
43
 
        self.wt = wt
44
 
        self.wtpath = wtpath
45
 
 
 
41
        self.gladefile = gladefile
 
42
        self.glade = gtk.glade.XML(self.gladefile, 'window_commit', 'olive-gtk')
 
43
        
 
44
        # Communication object
 
45
        self.comm = comm
 
46
        # Dialog object
 
47
        self.dialog = dialog
 
48
        
46
49
        # Get some important widgets
47
50
        self.window = self.glade.get_widget('window_commit')
48
51
        self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
49
52
        self.textview = self.glade.get_widget('textview_commit')
50
53
        self.file_view = self.glade.get_widget('treeview_commit_select')
51
54
 
52
 
        file_id = self.wt.path2id(wtpath)
 
55
        # Check if current location is a branch
 
56
        try:
 
57
            (self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
 
58
            branch = self.wt.branch
 
59
        except errors.NotBranchError:
 
60
            self.notbranch = True
 
61
            return
 
62
        except:
 
63
            raise
 
64
 
 
65
        file_id = self.wt.path2id(path)
53
66
 
54
67
        self.notbranch = False
55
68
        if file_id is None:
58
71
        
59
72
        # Set the delta
60
73
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
61
 
        self.delta = self.wt.changes_from(self.old_tree)
 
74
        if version_info < (0, 9):
 
75
            self.delta = compare_trees(self.old_tree, self.wt)
 
76
        else:
 
77
            self.delta = self.wt.changes_from(self.old_tree)
62
78
        
63
79
        # Dictionary for signal_autoconnect
64
80
        dic = { "on_button_commit_commit_clicked": self.commit,
73
89
    def display(self):
74
90
        """ Display the Push dialog. """
75
91
        if self.notbranch:
76
 
            error_dialog(_('Directory is not a branch'),
 
92
            self.dialog.error_dialog(_('Directory is not a branch'),
77
93
                                     _('You can perform this action only in a branch.'))
78
94
            self.close()
79
95
        else:
80
 
            if self.wt.branch.get_bound_location() is not None:
 
96
            from bzrlib.branch import Branch
 
97
            branch = Branch.open_containing(self.comm.get_path())[0]
 
98
 
 
99
            if branch.get_bound_location() is not None:
81
100
                # we have a checkout, so the local commit checkbox must appear
82
101
                self.checkbutton_local.show()
83
102
            
85
104
            self.window.show()
86
105
            
87
106
    
 
107
    # This code is from Jelmer Vernooij's bzr-gtk branch
88
108
    def _create_file_view(self):
89
109
        self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN,
90
110
                                        gobject.TYPE_STRING,
121
141
            it = self.file_store.iter_next(it)
122
142
 
123
143
        return ret
 
144
    # end of bzr-gtk code
124
145
    
125
146
    def _toggle_commit(self, cell, path, model):
126
147
        model[path][0] = not model[path][0]
136
157
        
137
158
        specific_files = self._get_specific_files()
138
159
        
 
160
        self.comm.set_busy(self.window)
 
161
        # merged from Jelmer Vernooij's olive integration branch
139
162
        try:
140
163
            self.wt.commit(message, 
141
164
                           allow_pointless=checkbutton_force.get_active(),
143
166
                           local=self.checkbutton_local.get_active(),
144
167
                           specific_files=specific_files)
145
168
        except errors.NotBranchError:
146
 
            error_dialog(_('Directory is not a branch'),
 
169
            self.dialog.error_dialog(_('Directory is not a branch'),
147
170
                                     _('You can perform this action only in a branch.'))
 
171
            self.comm.set_busy(self.window, False)
148
172
            return
149
173
        except errors.LocalRequiresBoundBranch:
150
 
            error_dialog(_('Directory is not a checkout'),
 
174
            self.dialog.error_dialog(_('Directory is not a checkout'),
151
175
                                     _('You can perform local commit only on checkouts.'))
 
176
            self.comm.set_busy(self.window, False)
152
177
            return
153
178
        except errors.PointlessCommit:
154
 
            error_dialog(_('No changes to commit'),
 
179
            self.dialog.error_dialog(_('No changes to commit'),
155
180
                                     _('Try force commit if you want to commit anyway.'))
 
181
            self.comm.set_busy(self.window, False)
156
182
            return
157
183
        except errors.ConflictsInTree:
158
 
            error_dialog(_('Conflicts in tree'),
 
184
            self.dialog.error_dialog(_('Conflicts in tree'),
159
185
                                     _('You need to resolve the conflicts before committing.'))
 
186
            self.comm.set_busy(self.window, False)
160
187
            return
161
188
        except errors.StrictCommitFailed:
162
 
            error_dialog(_('Strict commit failed'),
 
189
            self.dialog.error_dialog(_('Strict commit failed'),
163
190
                                     _('There are unknown files in the working tree.\nPlease add or delete them.'))
 
191
            self.comm.set_busy(self.window, False)
164
192
            return
165
193
        except errors.BoundBranchOutOfDate, errmsg:
166
 
            error_dialog(_('Bound branch is out of date'),
 
194
            self.dialog.error_dialog(_('Bound branch is out of date'),
167
195
                                     _('%s') % errmsg)
168
 
            return
169
 
        except errors.BzrError, msg:
170
 
            error_dialog(_('Unknown bzr error'), str(msg))
171
 
            return
172
 
        except Exception, msg:
173
 
            error_dialog(_('Unknown error'), str(msg))
174
 
            return
 
196
            self.comm.set_busy(self.window, False)
 
197
            return
 
198
        except:
 
199
            raise
175
200
        
176
201
        self.close()
 
202
        self.comm.refresh_right()
177
203
        
178
204
    def close(self, widget=None):
179
205
        self.window.destroy()