/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: Szilveszter Farkas (Phanatic)
  • Date: 2006-09-30 13:04:15 UTC
  • mto: (0.14.3 main)
  • mto: This revision was merged to the branch mainline in revision 86.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060930130415-aba4100709e11f0a
Loads of fixes. Pyflakes cleanup.

Show diffs side-by-side

added added

removed removed

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