/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-27 17:56:26 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060927175626-4462e9dc20d422b1
Bunch of random cleanups

Show diffs side-by-side

added added

removed removed

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