/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-30 10:21:43 UTC
  • Revision ID: jelmer@samba.org-20060930102143-c0ef64d6ca860c21
Merge some files from Olive and bzr-gtk.

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